Module

Data.Codec.Argonaut.Sum

Package
purescript-codec-argonaut
Repository
garyb/purescript-codec-argonaut

#Tag Source

newtype Tag

A tag value for a case in a sum type.

Constructors

Instances

#taggedSum Source

taggedSum :: forall a. (Tag -> Json -> Either JsonDecodeError a) -> (a -> Tuple Tag Json) -> JsonCodec a

A helper for defining JSON codecs for sum types.

  • The first function attempts to decode a case, using the specified tag.
  • The second function encodes a case, returning an appropriate tag and encoded value.