cereal-0.3.5.2: A binary serialization library

Stability | Portability :
Maintainer | Trevor Elliott <trevor@galois.com>
Safe Haskell | None

Data.Serialize

Contents

- The Serialize class
- Serialize serialisation

Description

Synopsis

- class Serialize t where
  - put :: Putter t
  - get :: Get t
- encode :: Serialize a => a -> ByteString
- encodeLazy :: Serialize a => a -> ByteString
- decode :: Serialize a => ByteString -> Either String a
- decodeLazy :: Serialize a => ByteString -> Either String a
- module Data.Serialize.Get
- module Data.Serialize.Put
- module Data.Serialize.IEEE754

# The Serialize class

class Serialize t where Source

If your compiler has support for the `DeriveGeneric` and `DefaultSignatures` language extensions (`ghc >= 7.2.1`), the `put` and `get` methods will have default generic implementations.

To use this option, simply add a `deriving `Generic`` clause to your datatype and declare a `Serialize` instance for it without giving a definition for `put` and `get`.

Methods

put :: Putter tSource

Encode a value in the Put monad.

get :: Get tSource

Decode a value in the Get monad

Instances

Serialize Bool |
Serialize Char |
Serialize Double |
Serialize Float |
Serialize Int |
Serialize Int8 |
Serialize Int16 |
Serialize Int32 |
Serialize Int64 |
Serialize Integer |
Serialize Ordering |
Serialize Word |
Serialize Word8 |
Serialize Word16 |
Serialize Word32 |
Serialize Word64 |
Serialize () |
Serialize ByteString |
Serialize ByteString |
Serialize IntSet |
Serialize a => Serialize [a] |
(Serialize a, Integral a) => Serialize (Ratio a) |
Serialize a => Serialize (Maybe a) |
Serialize e => Serialize (Tree e) |
Serialize e => Serialize (Seq e) |
Serialize e => Serialize (IntMap e) |
(Ord a, Serialize a) => Serialize (Set a) |
(Serialize a, Serialize b) => Serialize (Either a b) |
(Serialize a, Serialize b) => Serialize (a, b) |
(Serialize i, Ix i, Serialize e, IArray UArray e) => Serialize (UArray i e) |
(Serialize i, Ix i, Serialize e) => Serialize (Array i e) |
(Ord k, Serialize k, Serialize e) => Serialize (Map k e) |
(Serialize a, Serialize b, Serialize c) => Serialize (a, b, c) |
(Serialize a, Serialize b, Serialize c, Serialize d) => Serialize (a, b, c, d) |
(Serialize a, Serialize b, Serialize c, Serialize d, Serialize e) => Serialize (a, b, c, d, e) |
(Serialize a, Serialize b, Serialize c, Serialize d, Serialize e, Serialize f) => Serialize (a, b, c, d, e, f) |
(Serialize a, Serialize b, Serialize c, Serialize d, Serialize e, Serialize f, Serialize g) => Serialize (a, b, c, d, e, f, g) |
(Serialize a, Serialize b, Serialize c, Serialize d, Serialize e, Serialize f, Serialize g, Serialize h) => Serialize (a, b, c, d, e, f, g, h) |
(Serialize a, Serialize b, Serialize c, Serialize d, Serialize e, Serialize f, Serialize g, Serialize h, Serialize i) => Serialize (a, b, c, d, e, f, g, h, i) |
(Serialize a, Serialize b, Serialize c, Serialize d, Serialize e, Serialize f, Serialize g, Serialize h, Serialize i, Serialize j) => Serialize (a, b, c, d, e, f, g, h, i, j) |

# Serialize serialisation

encode :: Serialize a => a -> ByteString Source

Encode a value using binary serialization to a strict ByteString.

encodeLazy :: Serialize a => a -> ByteString Source

Encode a value using binary serialization to a lazy ByteString.

decode :: Serialize a => ByteString -> Either String aSource

Decode a value from a strict ByteString, reconstructing the original structure.

decodeLazy :: Serialize a => ByteString -> Either String aSource

Decode a value from a lazy ByteString, reconstructing the original structure.

module Data.Serialize.Get

module Data.Serialize.Put

module Data.Serialize.IEEE754