A Codec a contain a JSON Decoder a and the corresponding a -> Value encoder.
Represents a JavaScript value.
A structured error describing exactly how the decoder failed. You can use this to create more elaborate visualizations of a decoder problem. For example, you could show the entire JSON object and show the part causing the failure in red.
A value that knows how to decode JSON values.
Parse the given string into a JSON value and then run the Codec on it.
This will fail if the string is not well-formed JSON or if the Codec
fails for some reason.
Run a Codec to decode some JSON Value. You can send these JSON values
through ports, so that is probably the main time you would use this function.
Convert a value into a prettified JSON string. The first argument specifies the amount of indentation in the result string.
Convert a value into a Javascript Value.
Codec between a JSON array of length 2 and an Elm Tuple.
Codec between a JSON array of length 3 and an Elm triple.
A partially built Codec for an object.
Start creating a Codec for an object. You should pass the main constructor as argument.
If you don't have one (for example it's a simple type with no name), you should pass a function that given the field values builds an object.
Specify the name getter and Codec for a field.
Specify the name getter and Codec for an optional field.
This is particularly useful for evolving your Codecs.
Create a Codec from a fully specified ObjectCodec.
A partially built Codec for a custom type.
Starts building a Codec for a custom type.
You need to pass a pattern matching function, see the examples and FAQ for details.
Define a variant with 0 parameters for a custom type.
Define a variant with 1 parameters for a custom type.
Define a variant with 2 parameters for a custom type.
Define a variant with 3 parameters for a custom type.
Define a variant with 4 parameters for a custom type.
Define a variant with 5 parameters for a custom type.
Define a variant with 6 parameters for a custom type.
Define a variant with 7 parameters for a custom type.
Define a variant with 8 parameters for a custom type.
Build a Codec for a fully specified custom type.
Try a set of decoders (in order). The first argument is used for encoding and decoding, the list of other codecs is used as a fallback while decoding.
This is particularly useful for backwards compatibility. You would pass the current codec as the first argument,
and the old ones (eventually mapped) as a fallback list to use while decoding.
Create a Codec that produces null as JSON and always decodes as the same value.
A value that knows how to encode and decode JSON values.