Module
Data.Codec.Argonaut.Record
- Package
- purescript-codec-argonaut
- Repository
- garyb/purescript-codec-argonaut
#object Source
object :: forall ri ro rl. RowToList ri rl => RowListCodec rl ri ro => String -> Record ri -> JsonCodec (Record ro)
Constructs a JsonCodec
for a Record
from a name and a record of codecs.
The name is used in the error message produced when decoding fails.
type Person = { name ∷ String, age ∷ Int }
personCodec ∷ CA.JsonCodec Person
personCodec = CAR.object "Person" { name: CA.string, age: CA.int }
#record Source
record :: forall ri ro rl. RowToList ri rl => RowListCodec rl ri ro => Record ri -> JPropCodec (Record ro)
Constructs a JPropCodec
for a Record
from a record of codecs. Commonly
the object
function in this module will be the preferred choice, as that
produces a JsonCodec
instead.
#RowListCodec Source
class RowListCodec :: RowList Type -> Row Type -> Row Type -> Constraint
class RowListCodec (rl :: RowList Type) (ri :: Row Type) (ro :: Row Type) | rl -> ri ro where
The class used to enable the building of Record
codecs by providing a
record of codecs.
Members
rowListCodec :: forall proxy. proxy rl -> Record ri -> JPropCodec (Record ro)
Instances
RowListCodec Nil () ()
(RowListCodec rs ri' ro', Cons sym (JsonCodec a) ri' ri, Cons sym a ro' ro, IsSymbol sym, TypeEquals co (JsonCodec a)) => RowListCodec (Cons sym co rs) ri ro