| Safe Haskell | None |
|---|
Control.Pipe.Serialize
Contents
Description
This module provides the deserializer and serializer pipes to
convert ByteStrings off of pipes into typed values.
In order to use it, the types of the values need to have
Serialize instances. These can be derived automatically using
Ghc.Generics:
{-# LANGUAGE DeriveGeneric #-}
data Foo = Bar String | Baz Int
deriving ( Generic )
instance Serialize Foo
Note that in the above example: we use the DeriveGeneric
extension, derive a Generic instance for our data-type, and write
an empty Serialize instance.
- serializer :: (Serialize a, Monad m) => Pipe a ByteString m ()
- deserializer :: (Serialize a, Monad m) => Pipe ByteString a m ()
Pipes
serializer :: (Serialize a, Monad m) => Pipe a ByteString m ()Source
Serialize data into strict ByteStrings.
deserializer :: (Serialize a, Monad m) => Pipe ByteString a m ()Source
De-serialize data from strict ByteStrings. Uses cereal's
incremental Get parser.