| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Data.Row.Aeson
Contents
Description
This module defines orphan aeson instances for Row.
They differ from the instances in `row-types-aeson` in one crucial respect: they
serialise Nothing fields by *omitting* them in the resulting object, and parse absent fields as Nothing.
aeson can be configured to have this behviour for instances for datatypes, but we want to do this
for record types generically.
This is crucial to match what LSP clients expect.
Synopsis
- class ToJSONEntry a where
- toJSONEntry :: String -> a -> Object
- class FromJSONEntry a where
- parseJSONEntry :: Object -> String -> Parser a
- lazyUncons :: forall (l :: Symbol) (r :: Row Type). KnownSymbol l => Label l -> Rec r -> (Rec (r .- l), r .! l)
Documentation
class ToJSONEntry a where #
Serialise a value as an entry in a JSON object. This allows customizing the behaviour in the object context, in order to e.g. omit the field.
Methods
toJSONEntry :: String -> a -> Object #
Instances
| ToJSON a => ToJSONEntry a # | |
Defined in Data.Row.Aeson Methods toJSONEntry :: String -> a -> Object # | |
| ToJSON a => ToJSONEntry (Maybe a) # | |
Defined in Data.Row.Aeson Methods toJSONEntry :: String -> Maybe a -> Object # | |
class FromJSONEntry a where #
Methods
parseJSONEntry :: Object -> String -> Parser a #
Instances
| FromJSON a => FromJSONEntry a # | |
Defined in Data.Row.Aeson Methods parseJSONEntry :: Object -> String -> Parser a # | |
| FromJSON a => FromJSONEntry (Maybe a) # | |
Defined in Data.Row.Aeson | |
lazyUncons :: forall (l :: Symbol) (r :: Row Type). KnownSymbol l => Label l -> Rec r -> (Rec (r .- l), r .! l) #
Orphan instances
| (AllUniqueLabels r, Forall r FromJSONEntry) => FromJSON (Rec r) # | |
| Forall r ToJSONEntry => ToJSON (Rec r) # | |