bynk.types.json_uncodable
Error A Json.encode/Json.decode target type cannot pass through the typed JSON codec (functions, effects, streams or a type that carries one, bynk.crypto keys, error builtins).
Json.encode and Json.decode work on values that have a wire form, and a function does not: a value that can run has no JSON text to stand for it. The codec covers the base types, named types and the built-in containers over them. It does not cover functions, effects, streams or a type that carries one, bynk.crypto keys or the error builtins. Encode the data the function produces, or the record that describes it, not the function itself.
Example
fn dump(f: Int -> Int) -> String { Json.encode(f) // ✗ a function has no JSON form}
fn dump(f: Int -> Int) -> String { Json.encode(f(1)) // ✓ encode a value it produces}In the Book
See also
- The grammar rule it governs:
method_call. - Every code in its category, Type checking, on the diagnostic index.
bynk explain bynk.types.json_uncodableshows the same from the installed toolchain, without a network.