HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleautodocodec-0.5.0.0Haskell2010

Autodocodec.Class

  • 2 classes
  • 14 values
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.

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

    Key

  3. -> Text

    Documentation

  4. -> ObjectCodec (Maybe output) (Maybe output)
#

An optional, or null, field

During decoding, the field may be in the object. Nothing will be parsed if it is not. If the field is null, then it will be parsed as Nothing as well.

During encoding, the field will be in the object if it is not Nothing, and omitted otherwise.