Module

Data.Codec

#GCodec

data GCodec m n a b

Constructors

Instances

#decoder

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

Extracts the decoder part of a GCodec

#encoder

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

Extracts the encoder part of a GCodec

#bihoistGCodec

bihoistGCodec :: forall m m' n n' a b. (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.

#(~)

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

GCodec is defined as a Profunctor so that lcmap 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

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

#codec

codec :: forall m a b c d. (a -> m d) -> (c -> Tuple d b) -> Codec m a b c d

#decode

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

#encode

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

#mapCodec

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

#composeCodec

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

#(<~<)

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

#composeCodecFlipped

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

#(>~>)

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

#hoistCodec

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

#BasicCodec

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

#basicCodec

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

Modules