Safe Haskell | None |
---|---|
Language | Haskell2010 |
Various examples of using saison
.
SomeValue
SomeValue
is a dummy object.
Decoding it from a JSON value always succeeds,
but we don't preserve any information about that value.
If we decode a list [
, we can then SomeValue
]count
values in it.
This is an extreme example where saison
approach shines.
instanceFromTokens
SomeValue
wherefromTokens
= \toks ->SomeValue
<$
skipValue
toks
Instances
Eq SomeValue Source # | |
Ord SomeValue Source # | |
Defined in Saison.Decoding.Examples | |
Show SomeValue Source # | |
NFData SomeValue Source # | |
Defined in Saison.Decoding.Examples | |
FromJSON SomeValue Source # | |
Defined in Saison.Decoding.Examples parseJSON :: Value -> Parser SomeValue parseJSONList :: Value -> Parser [SomeValue] | |
ToJSON SomeValue Source # | |
Defined in Saison.Decoding.Examples toEncoding :: SomeValue -> Encoding toJSONList :: [SomeValue] -> Value toEncodingList :: [SomeValue] -> Encoding | |
FromTokens SomeValue Source # | |
Laureates
is a wrapper around a list of elements.Laureates
a
The laureate.json
database is a json of form
{ "laureates": [ ... ] }
This type parses the outer layer.
Laureates | |
|
Instances
Eq a => Eq (Laureates a) Source # | |
Show a => Show (Laureates a) Source # | |
NFData a => NFData (Laureates a) Source # | |
Defined in Saison.Decoding.Examples | |
FromJSON a => FromJSON (Laureates a) Source # | |
Defined in Saison.Decoding.Examples parseJSON :: Value -> Parser (Laureates a) parseJSONList :: Value -> Parser [Laureates a] | |
FromTokens a => FromTokens (Laureates a) Source # | This instance differs from
|
Almost complete information about a laureate. We skip "prizes"
information.
Look at the implementaton of FromJSON
and FromTokens
instances,
they don't look that much different.