-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Simple bidirectional serialization
--
-- See README.md
@package codec
@version 0.2
module Control.Monad.Codec
-- | A serializer/deserializer pair reading a in context
-- r and writing c in context w.
data CodecFor r w c a
Codec :: r a -> (c -> w a) -> CodecFor r w c a
[codecIn] :: CodecFor r w c a -> r a
[codecOut] :: CodecFor r w c a -> c -> w a
type Codec r w a = CodecFor r w a a
-- | Compose a function into the serializer of a Codec. Useful to
-- modify a Codec so that it writes a particular record field.
(=.) :: (c' -> c) -> CodecFor r w c a -> CodecFor r w c' a
-- | Modify a serializer function so that it also returns the serialized
-- value, Useful for implementing codecs.
fmapArg :: Functor f => (a -> f ()) -> a -> f a
instance (GHC.Base.Functor w, GHC.Base.Functor r) => GHC.Base.Functor (Control.Monad.Codec.CodecFor r w c)
instance (GHC.Base.Applicative r, GHC.Base.Applicative w) => GHC.Base.Applicative (Control.Monad.Codec.CodecFor r w c)
instance (GHC.Base.Monad r, GHC.Base.Monad w) => GHC.Base.Monad (Control.Monad.Codec.CodecFor r w c)
instance (GHC.Base.Functor r, GHC.Base.Functor w) => Data.Profunctor.Unsafe.Profunctor (Control.Monad.Codec.CodecFor r w)
module Data.Aeson.Codec
-- | Describes the de/serialization of a type a. Equivalent to a
-- ToJSON and a FromJSON instance.
data JSONCodec a
JSONCodec :: (Value -> Parser a) -> (a -> Value) -> (a -> Encoding) -> JSONCodec a
[parseJSONCodec] :: JSONCodec a -> Value -> Parser a
[toJSONCodec] :: JSONCodec a -> a -> Value
[toEncodingCodec] :: JSONCodec a -> a -> Encoding
-- | Encode/decode a value with its ToJSON and FromJSON
-- instances.
defJSON :: (FromJSON a, ToJSON a) => JSONCodec a
type ObjectParser = ReaderT Object Parser
type ObjectBuilder = Writer (Series, Endo [Pair])
-- | A codec that parses values out of a given Object, and produces
-- key-value pairs into a new one.
type ObjectCodec a = Codec ObjectParser ObjectBuilder a
-- | Store/retrieve a value in a given JSON field, with the default JSON
-- serialization.
field :: (FromJSON a, ToJSON a) => Text -> ObjectCodec a
-- | Store/retrieve a value in a given JSON field, with a given JSONCodec.
field' :: Text -> JSONCodec a -> ObjectCodec a
-- | Turn an ObjectCodec into a JSONCodec with an expected
-- name (see withObject).
asObject :: String -> ObjectCodec a -> JSONCodec a
type ArrayParser = StateT [Value] Parser
type ArrayBuilder = Writer (Series, [Value])
-- | A codec that serializes data to a sequence of JSON array elements.
type ArrayCodec a = Codec ArrayParser ArrayBuilder a
-- | Expect/append an array element, using the default serialization.
element :: (FromJSON a, ToJSON a) => ArrayCodec a
-- | Expect/append an array element, using a given JSONCodec.
element' :: JSONCodec a -> ArrayCodec a
-- | A codec that parses values out of a given Array, and produces
-- key-value pairs into a new one.
asArray :: String -> ArrayCodec a -> JSONCodec a
-- | Given a a way to turn a into [ b ] and back, create
-- a JSONCodec for a.
arrayOf :: (FromJSON b, ToJSON b) => (a -> [b]) -> ([b] -> a) -> JSONCodec a
-- | Given a JSONCodec for b and a way to turn a
-- into [ b ] and back, create a JSONCodec for
-- a.
arrayOf' :: (a -> [b]) -> ([b] -> a) -> JSONCodec b -> JSONCodec a
module Data.Binary.Codec
type BinaryCodec a = Codec Get PutM a
-- | Get/put an n-byte field.
byteString :: Int -> BinaryCodec ByteString
word8 :: BinaryCodec Word8
word16be :: BinaryCodec Word16
word16le :: BinaryCodec Word16
word16host :: BinaryCodec Word16
word32be :: BinaryCodec Word32
word32le :: BinaryCodec Word32
word32host :: BinaryCodec Word32
word64be :: BinaryCodec Word64
word64le :: BinaryCodec Word64
word64host :: BinaryCodec Word64
wordhost :: BinaryCodec Word
int8 :: BinaryCodec Int8
int16be :: BinaryCodec Int16
int16le :: BinaryCodec Int16
int16host :: BinaryCodec Int16
int32be :: BinaryCodec Int32
int32le :: BinaryCodec Int32
int32host :: BinaryCodec Int32
int64be :: BinaryCodec Int64
int64le :: BinaryCodec Int64
int64host :: BinaryCodec Int64
inthost :: BinaryCodec Int
module Data.Binary.Bits.Codec
type BitCodec a = Codec Block BitPut a
bool :: BitCodec Bool
word8 :: Int -> BitCodec Word8
word16be :: Int -> BitCodec Word16
word32be :: Int -> BitCodec Word32
word64be :: Int -> BitCodec Word64
-- | Convert a BitCodec into a BinaryCodec.
toBytes :: BitCodec a -> BinaryCodec a