Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- class HasCodec value where
- codec :: JSONCodec value
- listCodecForStringCompatibility :: JSONCodec [value]
- class HasObjectCodec object where
- objectCodec :: JSONObjectCodec object
- requiredField :: HasCodec output => Text -> Text -> ObjectCodec output output
- requiredField' :: HasCodec output => Text -> ObjectCodec output output
- optionalField :: HasCodec output => Text -> Text -> ObjectCodec (Maybe output) (Maybe output)
- optionalField' :: HasCodec output => Text -> ObjectCodec (Maybe output) (Maybe output)
- optionalFieldWithDefault :: HasCodec output => Text -> output -> Text -> ObjectCodec output output
- optionalFieldWithDefault' :: HasCodec output => Text -> output -> ObjectCodec output output
- optionalFieldOrNull :: forall output. HasCodec output => Text -> Text -> ObjectCodec (Maybe output) (Maybe output)
- optionalFieldOrNull' :: forall output. HasCodec output => Text -> ObjectCodec (Maybe output) (Maybe output)
- optionalFieldWithOmittedDefault :: (Eq output, HasCodec output) => Text -> output -> Text -> ObjectCodec output output
- optionalFieldWithOmittedDefault' :: (Eq output, HasCodec output) => Text -> output -> ObjectCodec output output
- optionalFieldOrNullWithOmittedDefault :: (Eq output, HasCodec output) => Text -> output -> Text -> ObjectCodec output output
- optionalFieldOrNullWithOmittedDefault' :: (Eq output, HasCodec output) => Text -> output -> ObjectCodec output output
Documentation
class HasCodec value where Source #
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."
codec :: JSONCodec value Source #
A codec for a single value
See the sections on helper functions for implementing this for plenty of examples.
listCodecForStringCompatibility :: JSONCodec [value] Source #
Instances
class HasObjectCodec object where Source #
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."
objectCodec :: JSONObjectCodec object Source #
A object codec for the value
See the sections on helper functions for implementing this for plenty of examples.
:: HasCodec output | |
=> Text | Key |
-> Text | Documentation |
-> ObjectCodec output output |
A required field
During decoding, the field must be in the object.
During encoding, the field will always be in the object.
:: HasCodec output | |
=> Text | Key |
-> ObjectCodec output output |
Like requiredField
, but without documentation
:: HasCodec output | |
=> Text | Key |
-> ObjectCodec (Maybe output) (Maybe output) |
Like optionalField
, but without documentation
optionalFieldWithDefault Source #
:: HasCodec output | |
=> Text | Key |
-> output | Default value |
-> Text | Documentation |
-> 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.
optionalFieldWithDefault' Source #
:: HasCodec output | |
=> Text | Key |
-> output | Default value |
-> ObjectCodec output output |
Like optionalFieldWithDefault
, but without documentation
:: forall output. HasCodec output | |
=> Text | Key |
-> ObjectCodec (Maybe output) (Maybe output) |
Like optionalFieldOrNull
, but without documentation
optionalFieldWithOmittedDefault Source #
:: (Eq output, HasCodec output) | |
=> Text | Key |
-> output | Default value |
-> Text | Documentation |
-> ObjectCodec output output |
optionalFieldWithOmittedDefault' Source #
:: (Eq output, HasCodec output) | |
=> Text | Key |
-> output | Default value |
-> ObjectCodec output output |
optionalFieldOrNullWithOmittedDefault Source #
:: (Eq output, HasCodec output) | |
=> Text | Key |
-> output | Default value |
-> Text | Documentation |
-> ObjectCodec output output |
optionalFieldOrNullWithOmittedDefault' Source #
:: (Eq output, HasCodec output) | |
=> Text | Key |
-> output | Default value |
-> ObjectCodec output output |