Data.Argonaut.Encode.Generic.Rep
- Package
- purescript-argonaut-generic
- Repository
- purescript-contrib/purescript-argonaut-generic
#EncodeRep Source
class EncodeRep r where
Members
Instances
EncodeRep NoConstructors
(EncodeRep a, EncodeRep b) => EncodeRep (Sum a b)
(IsSymbol name, EncodeRepArgs a) => EncodeRep (Constructor name a)
#EncodeRepArgs Source
class EncodeRepArgs r where
Members
encodeRepArgs :: r -> Array Json
Instances
EncodeRepArgs NoArguments
(EncodeRepArgs a, EncodeRepArgs b) => EncodeRepArgs (Product a b)
(RowToList row rl, EncodeRepRowList rl row) => EncodeRepArgs (Argument (Record row))
(EncodeJson a) => EncodeRepArgs (Argument a)
#EncodeRepFields Source
class EncodeRepFields r where
Members
encodeRepFields :: r -> Object Json
Instances
(EncodeRepFields a, EncodeRepFields b) => EncodeRepFields (Product a b)
#EncodeRepRowList Source
class EncodeRepRowList (rl :: RowList) (row :: Row Type) | rl -> row where
a EncodeRepRowList
represents a relation between a RowList
and a record you
can serialize into a Json Object
this one is strictly internal to help out encodeRepRecordArgument
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 use the Cons
cases to to compose functions that adds the field
and values from the given record into a Json-Object
the field in question is indicated by the head of the RowList
the Nil
case just returns identity
to bootstrap the composition-chain
Members
Instances
EncodeRepRowList Nil row
(EncodeJson ty, IsSymbol name, EncodeRepRowList tail row, Cons name ty ignore row) => EncodeRepRowList (Cons name ty tail) row
#EncodeLiteral Source
class EncodeLiteral r where
Members
encodeLiteral :: (String -> String) -> r -> Json
Instances
(EncodeLiteral a, EncodeLiteral b) => EncodeLiteral (Sum a b)
(IsSymbol name) => EncodeLiteral (Constructor name NoArguments)
#genericEncodeJson Source
genericEncodeJson :: forall r a. Generic a r => EncodeRep r => a -> Json
Encode any Generic
data structure into Json
.
#encodeLiteralSum Source
encodeLiteralSum :: forall r a. Generic a r => EncodeLiteral r => a -> Json
A function for encoding Generic
sum types using string literal representations
#encodeLiteralSumWithTransform Source
encodeLiteralSumWithTransform :: forall r a. Generic a r => EncodeLiteral r => (String -> String) -> a -> Json
A function for encoding Generic
sum types using string literal representations
Takes a function for transforming the tag name in encoding