Module
Codec.Decoder
- Package
- purescript-json-codecs
- Repository
- jordanmartinez/purescript-json-codecs
#DecoderFn Source
newtype DecoderFn path handlers e extra from to
Think of this as
forall e
. Semigroup e
=> { path :: path -- current 'path' in `from` value (e.g. Json)
, handlers :: handlers -- handlers for building custom error
, extra :: extra -- a slot for any extra goodies (e.g. "local" type class instances)
}
-> from -- value being decoded
-> V e to -- monad that
-- 1. fails with accumulated error using `<>`, or
-- 2. succeeds with `to` value
but where
- the
from -> V e to
function has been converted to an uncurried function:Fn1 from (V e to)
- each of the record's labels has been spread into "slots" in an uncurried function
Fn1 from (V e to)
->Fn4 path handler extra from (V e to)
- and the
Semigroup
'sappend
/<>
has been inlined to reduce type class dictionary overheadFn4 path handler extra from (V e to)
->Fn5 path appendFn handler extra from (V e to)
Constructors
Instances
#altAccumulate Source
altAccumulate :: forall path handlers e extra from a. DecoderFn path handlers e extra from a -> DecoderFn path handlers e extra from a -> DecoderFn path handlers e extra from a
Works like alt
/<|>
. Decodes using the first decoder and, if that fails,
decodes using the second decoder. Errors from both decoders accumulate.
#altLast Source
altLast :: forall path handlers e extra from a. DecoderFn path handlers e extra from a -> DecoderFn path handlers e extra from a -> DecoderFn path handlers e extra from a
Same as altAccumulate
except only the last error is kept. Helpful in cases
where one is decoding a sum type with a large number of data constructors.
- Modules
- Codec.
Codec - Codec.
Decoder - Codec.
Decoder. Qualified - Codec.
Json. Bidirectional. Class - Codec.
Json. Bidirectional. Value - Codec.
Json. Errors. AnsiDodoError - Codec.
Json. Errors. DecodeMessages - Codec.
Json. Errors. NoError - Codec.
Json. Errors. PlainDodoError - Codec.
Json. Errors. PrimitiveJsonError - Codec.
Json. Errors. Tree - Codec.
Json. JsonCodec - Codec.
Json. JsonDecoder - Codec.
Json. Newtypes - Codec.
Json. Types - Codec.
Json. Unidirectional. Decode. Class - Codec.
Json. Unidirectional. Decode. Value - Codec.
Json. Unidirectional. Encode. Class - Codec.
Json. Unidirectional. Encode. Value - Data.
V. Semigroup. Qualified