codec-0.2.1: Simple bidirectional serialization

Safe HaskellSafe
LanguageHaskell2010

Control.Monad.Codec

Synopsis

Documentation

data CodecFor r w c a Source #

A serializer/deserializer pair reading a in context r and writing c in context w.

Constructors

Codec 

Fields

Instances

(Functor r, Functor w) => Profunctor (CodecFor r w) Source # 

Methods

dimap :: (a -> b) -> (c -> d) -> CodecFor r w b c -> CodecFor r w a d #

lmap :: (a -> b) -> CodecFor r w b c -> CodecFor r w a c #

rmap :: (b -> c) -> CodecFor r w a b -> CodecFor r w a c #

(#.) :: Coercible * c b => (b -> c) -> CodecFor r w a b -> CodecFor r w a c #

(.#) :: Coercible * b a => CodecFor r w b c -> (a -> b) -> CodecFor r w a c #

(Monad r, Monad w) => Monad (CodecFor r w c) Source # 

Methods

(>>=) :: CodecFor r w c a -> (a -> CodecFor r w c b) -> CodecFor r w c b #

(>>) :: CodecFor r w c a -> CodecFor r w c b -> CodecFor r w c b #

return :: a -> CodecFor r w c a #

fail :: String -> CodecFor r w c a #

(Functor w, Functor r) => Functor (CodecFor r w c) Source # 

Methods

fmap :: (a -> b) -> CodecFor r w c a -> CodecFor r w c b #

(<$) :: a -> CodecFor r w c b -> CodecFor r w c a #

(Applicative r, Applicative w) => Applicative (CodecFor r w c) Source # 

Methods

pure :: a -> CodecFor r w c a #

(<*>) :: CodecFor r w c (a -> b) -> CodecFor r w c a -> CodecFor r w c b #

(*>) :: CodecFor r w c a -> CodecFor r w c b -> CodecFor r w c b #

(<*) :: CodecFor r w c a -> CodecFor r w c b -> CodecFor r w c a #

type Codec r w a = CodecFor r w a a Source #

(=.) :: (c' -> c) -> CodecFor r w c a -> CodecFor r w c' a Source #

Compose a function into the serializer of a Codec. Useful to modify a Codec so that it writes a particular record field.

fmapArg :: Functor f => (a -> f ()) -> a -> f a Source #

Modify a serializer function so that it also returns the serialized value, Useful for implementing codecs.