Safe Haskell | None |
---|
This module provides the deserializer
and serializer
pipes to
convert ByteString
s 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 ByteString
s.
deserializer :: (Serialize a, Monad m) => Pipe ByteString a m ()Source
De-serialize data from strict ByteString
s. Uses cereal
's
incremental Get
parser.