HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

classclass HasCodec value where

A class for values which have a canonical codec.

There are no formal laws for this class. If you really want a law, it should be "Whomever uses the codec from your instance should not be surprised."

Methods

  • codec :: JSONCodec value

    A codec for a single value

    See the sections on helper functions for implementing this for plenty of examples.

  • listCodecForStringCompatibility :: JSONCodec [value]

    A codec for a list of values

    This is really only useful for cases like Char and String. We didn't call it listCodec so we could use that name for making a codec for a list of values from a single codec instead.

Instances45HasCodec, …
classclass HasObjectCodec object where

A class for values which have a canonical object codec.

There are no formal laws for this class. If you really want a law, it should be "Whomever uses the codec from your instance should not be surprised."

Methods

  • objectCodec :: JSONObjectCodec object

    A object codec for the value

    See the sections on helper functions for implementing this for plenty of examples.

valueoptionalFieldWithDefault
  1. :: HasCodec output
  2. => Text

    Key

  3. -> output

    Default value

  4. -> Text

    Documentation

  5. -> ObjectCodec output output

An optional field with a default value

During decoding, the field may be in the object. The default value will be parsed otherwise.

During encoding, the field will be in the object. The default value is ignored.

The shown version of the default value will appear in the documentation.