Module

Data.Codec

Package
purescript-codec
Repository
garyb/purescript-codec

#GCodec Source

data GCodec m n a b

A general type for codecs.

Constructors

Instances

#decoder Source

decoder :: forall b a n m. GCodec m n a b -> m b

Extracts the decoder part of a GCodec

#encoder Source

encoder :: forall b a n m. GCodec m n a b -> Star n a b

Extracts the encoder part of a GCodec

#bihoistGCodec Source

bihoistGCodec :: forall b a n' n m' m. (m ~> m') -> (n ~> n') -> GCodec m n a b -> GCodec m' n' a b

Changes the m and n functors used in the codec using the specified natural transformations.

#(~) Source

Operator alias for Data.Profunctor.lcmap (left-associative / precedence 5)

GCodec is defined as a Profunctor so that lmap can be used to target specific fields when defining a codec for a product type. This operator is a convenience for that:

tupleCodec =
  Tuple
    <$> fst ~ fstCodec
    <*> snd ~ sndCodec

#Codec Source

type Codec m a b c d = GCodec (ReaderT a m) (Writer b) c d

#decode Source

decode :: forall d c b a m. Codec m a b c d -> a -> m d

#encode Source

encode :: forall d c b a m. Codec m a b c d -> c -> b

#mapCodec Source

mapCodec :: forall d c b a m. Bind m => (a -> m b) -> (b -> a) -> Codec m c d a a -> Codec m c d b b

#composeCodec Source

composeCodec :: forall m c e b f d a. Bind m => Codec m d c e f -> Codec m a b c d -> Codec m a b e f

#(<~<) Source

Operator alias for Data.Codec.composeCodec (right-associative / precedence 8)

#composeCodecFlipped Source

composeCodecFlipped :: forall m c e b f d a. Bind m => Codec m a b c d -> Codec m d c e f -> Codec m a b e f

#(>~>) Source

Operator alias for Data.Codec.composeCodecFlipped (right-associative / precedence 8)

#hoistCodec Source

hoistCodec :: forall d c b a m' m. (m ~> m') -> Codec m a b c d -> Codec m' a b c d

#BasicCodec Source

type BasicCodec m a b = Codec m a a b b

#basicCodec Source

basicCodec :: forall b a m. (a -> m b) -> (b -> a) -> BasicCodec m a b
Modules
Data.Codec