Data.Argonaut.Decode.Generic.Rep
- Package
- purescript-argonaut-generic
- Repository
- purescript-contrib/purescript-argonaut-generic
#DecodeRep Source
class DecodeRep r where
Members
Instances
DecodeRep NoConstructors
(DecodeRep a, DecodeRep b) => DecodeRep (Sum a b)
(IsSymbol name, DecodeRepArgs a) => DecodeRep (Constructor name a)
#DecodeRepArgs Source
class DecodeRepArgs r where
Members
Instances
DecodeRepArgs NoArguments
(DecodeRepArgs a, DecodeRepArgs b) => DecodeRepArgs (Product a b)
(RowToList row rl, DecodeRepRowList rl () row) => DecodeRepArgs (Argument (Record row))
(DecodeJson a) => DecodeRepArgs (Argument a)
#DecodeRepRowList Source
class DecodeRepRowList (rl :: RowList) (from :: Row Type) (to :: Row Type) | rl -> from to where
a DecodeRepRowList
represents a relation between a RowList
and a record you
can build from it by deserializing it's fields from a JSON Object
this one is strictly internal to help out decodeRepRecordArgument
handling records
a RowList
on the type level is very similar to a cons-list on the value level
so the two instances handle all possible RowList
s
the idea is to use Builder
to convert a RowList
into a record at the type-level
and have decodeRepRowList
as witness on the value level that will try to decode
JSON in to the resulting record value
from
and to
are two helper types - using these decodeRepRowListCons
can
recursively create Builder
-steps and make sure that every symbol in rl
can only occur once (the fields in the records must be unique)
(see Row.Lacks
)
Members
decodeRepRowList :: forall g. g rl -> Object Json -> Either String (Builder (Record from) (Record to))
Instances
DecodeRepRowList Nil () ()
(DecodeJson ty, IsSymbol name, DecodeRepRowList tail from from', Lacks name from', Cons name ty from' to) => DecodeRepRowList (Cons name ty tail) from to
#DecodeLiteral Source
class DecodeLiteral r where
Members
Instances
(DecodeLiteral a, DecodeLiteral b) => DecodeLiteral (Sum a b)
(IsSymbol name) => DecodeLiteral (Constructor name NoArguments)
#decodeLiteralSum Source
decodeLiteralSum :: forall r a. Generic a r => DecodeLiteral r => Json -> Either String a
A function for decoding Generic
sum types using string literal representations
#decodeLiteralSumWithTransform Source
decodeLiteralSumWithTransform :: forall r a. Generic a r => DecodeLiteral r => (String -> String) -> Json -> Either String a
A function for decoding Generic
sum types using string literal representations
Takes a function for transforming the tag name in encoding