cereal-0.5.4.0: A binary serialization library

Copyright | Lennart Kolmodin Galois Inc. 2009
License | BSD3-style (see LICENSE)
Maintainer | Trevor Elliott <trevor@galois.com>
Stability | Portability :
Safe Haskell | None
Language | Haskell2010

Data.Serialize

Contents

- The Serialize class
- Serialize serialisation
- Generic deriving

Description

Synopsis

- class Serialize t where
- encode :: Serialize a => a -> ByteString
- encodeLazy :: Serialize a => a -> ByteString
- decode :: Serialize a => ByteString -> Either String a
- decodeLazy :: Serialize a => ByteString -> Either String a
- expect :: (Eq a, Serialize a) => a -> Get a
- module Data.Serialize.Get
- module Data.Serialize.Put
- module Data.Serialize.IEEE754
- class GSerializePut f where
- class GSerializeGet f where

# 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 t Source #

Encode a value in the Put monad.

get :: Get t Source #

Decode a value in the Get monad

put :: (Generic t, GSerializePut (Rep t)) => Putter t Source #

Encode a value in the Put monad.

get :: (Generic t, GSerializeGet (Rep t)) => Get t Source #

Decode a value in the Get monad

Instances

Serialize Bool Source # |
Methods put :: Putter Bool Source # get :: Get Bool Source #
Serialize Char Source # |
Methods put :: Putter Char Source # get :: Get Char Source #
Serialize Double Source # |
Methods put :: Putter Double Source # get :: Get Double Source #
Serialize Float Source # |
Methods put :: Putter Float Source # get :: Get Float Source #
Serialize Int Source # |
Methods put :: Putter Int Source # get :: Get Int Source #
Serialize Int8 Source # |
Methods put :: Putter Int8 Source # get :: Get Int8 Source #
Serialize Int16 Source # |
Methods put :: Putter Int16 Source # get :: Get Int16 Source #
Serialize Int32 Source # |
Methods put :: Putter Int32 Source # get :: Get Int32 Source #
Serialize Int64 Source # |
Methods put :: Putter Int64 Source # get :: Get Int64 Source #
Serialize Integer Source # |
Methods put :: Putter Integer Source # get :: Get Integer Source #
Serialize Ordering Source # |
Methods put :: Putter Ordering Source # get :: Get Ordering Source #
Serialize Word Source # |
Methods put :: Putter Word Source # get :: Get Word Source #
Serialize Word8 Source # |
Methods put :: Putter Word8 Source # get :: Get Word8 Source #
Serialize Word16 Source # |
Methods put :: Putter Word16 Source # get :: Get Word16 Source #
Serialize Word32 Source # |
Methods put :: Putter Word32 Source # get :: Get Word32 Source #
Serialize Word64 Source # |
Methods put :: Putter Word64 Source # get :: Get Word64 Source #
Serialize () Source # |
Methods put :: Putter () Source # get :: Get () Source #
Serialize Natural Source # |
Methods put :: Putter Natural Source # get :: Get Natural Source #
Serialize All Source # |
Methods put :: Putter All Source # get :: Get All Source #
Serialize Any Source # |
Methods put :: Putter Any Source # get :: Get Any Source #
Serialize ByteString Source # |
Methods put :: Putter ByteString Source # get :: Get ByteString Source #
Serialize ByteString Source # |
Methods put :: Putter ByteString Source # get :: Get ByteString Source #
Serialize IntSet Source # |
Methods put :: Putter IntSet Source # get :: Get IntSet Source #
Serialize a => Serialize [a] Source # |
Methods put :: Putter [a] Source # get :: Get [a] Source #
Serialize a => Serialize (Maybe a) Source # |
Methods put :: Putter (Maybe a) Source # get :: Get (Maybe a) Source #
(Serialize a, Integral a) => Serialize (Ratio a) Source # |
Methods put :: Putter (Ratio a) Source # get :: Get (Ratio a) Source #
Serialize a => Serialize (Dual a) Source # |
Methods put :: Putter (Dual a) Source # get :: Get (Dual a) Source #
Serialize a => Serialize (Sum a) Source # |
Methods put :: Putter (Sum a) Source # get :: Get (Sum a) Source #
Serialize a => Serialize (Product a) Source # |
Methods put :: Putter (Product a) Source # get :: Get (Product a) Source #
Serialize a => Serialize (First a) Source # |
Methods put :: Putter (First a) Source # get :: Get (First a) Source #
Serialize a => Serialize (Last a) Source # |
Methods put :: Putter (Last a) Source # get :: Get (Last a) Source #
Serialize e => Serialize (IntMap e) Source # |
Methods put :: Putter (IntMap e) Source # get :: Get (IntMap e) Source #
Serialize e => Serialize (Tree e) Source # |
Methods put :: Putter (Tree e) Source # get :: Get (Tree e) Source #
Serialize e => Serialize (Seq e) Source # |
Methods put :: Putter (Seq e) Source # get :: Get (Seq e) Source #
(Ord a, Serialize a) => Serialize (Set a) Source # |
Methods put :: Putter (Set a) Source # get :: Get (Set a) Source #
(Serialize a, Serialize b) => Serialize (Either a b) Source # |
Methods put :: Putter (Either a b) Source # get :: Get (Either a b) Source #
(Serialize a, Serialize b) => Serialize (a, b) Source # |
Methods put :: Putter (a, b) Source # get :: Get (a, b) Source #
(Serialize i, Ix i, Serialize e, IArray UArray e) => Serialize (UArray i e) Source # |
Methods put :: Putter (UArray i e) Source # get :: Get (UArray i e) Source #
(Serialize i, Ix i, Serialize e) => Serialize (Array i e) Source # |
Methods put :: Putter (Array i e) Source # get :: Get (Array i e) Source #
(Ord k, Serialize k, Serialize e) => Serialize (Map k e) Source # |
Methods put :: Putter (Map k e) Source # get :: Get (Map k e) Source #
(Serialize a, Serialize b, Serialize c) => Serialize (a, b, c) Source # |
Methods put :: Putter (a, b, c) Source # get :: Get (a, b, c) Source #
(Serialize a, Serialize b, Serialize c, Serialize d) => Serialize (a, b, c, d) Source # |
Methods put :: Putter (a, b, c, d) Source # get :: Get (a, b, c, d) Source #
(Serialize a, Serialize b, Serialize c, Serialize d, Serialize e) => Serialize (a, b, c, d, e) Source # |
Methods put :: Putter (a, b, c, d, e) Source # get :: Get (a, b, c, d, e) Source #
(Serialize a, Serialize b, Serialize c, Serialize d, Serialize e, Serialize f) => Serialize (a, b, c, d, e, f) Source # |
Methods put :: Putter (a, b, c, d, e, f) Source # get :: Get (a, b, c, d, e, f) Source #
(Serialize a, Serialize b, Serialize c, Serialize d, Serialize e, Serialize f, Serialize g) => Serialize (a, b, c, d, e, f, g) Source # |
Methods put :: Putter (a, b, c, d, e, f, g) Source # get :: Get (a, b, c, d, e, f, g) Source #
(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) Source # |
Methods put :: Putter (a, b, c, d, e, f, g, h) Source # get :: Get (a, b, c, d, e, f, g, h) Source #
(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) Source # |
Methods put :: Putter (a, b, c, d, e, f, g, h, i) Source # get :: Get (a, b, c, d, e, f, g, h, i) Source #
(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) Source # |
Methods put :: Putter (a, b, c, d, e, f, g, h, i, j) Source # get :: Get (a, b, c, d, e, f, g, h, i, j) Source #

# 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 a Source #

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

decodeLazy :: Serialize a => ByteString -> Either String a Source #

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

expect :: (Eq a, Serialize a) => a -> Get a Source #

Perform an action, failing if the read result does not match the argument provided.

module Data.Serialize.Get

module Data.Serialize.Put

module Data.Serialize.IEEE754

# Generic deriving

class GSerializePut f where Source #

Minimal complete definition

gPut

Methods

gPut :: Putter (f a) Source #

Instances

GSerializePut U1 Source # |
Methods gPut :: Putter (U1 a) Source #
Serialize a => GSerializePut (K1 i a) Source # |
Methods gPut :: Putter (K1 i a a) Source #
(PutSum a, PutSum b, SumSize a, SumSize b) => GSerializePut ((:+:) a b) Source # |
Methods gPut :: Putter ((a :+: b) a) Source #
(GSerializePut a, GSerializePut b) => GSerializePut ((:*:) a b) Source # |
Methods gPut :: Putter ((a :*: b) a) Source #
GSerializePut a => GSerializePut (M1 i c a) Source # |
Methods gPut :: Putter (M1 i c a a) Source #

class GSerializeGet f where Source #

Minimal complete definition

gGet

Methods

gGet :: Get (f a) Source #

Instances

GSerializeGet U1 Source # |
Methods gGet :: Get (U1 a) Source #
Serialize a => GSerializeGet (K1 i a) Source # |
Methods gGet :: Get (K1 i a a) Source #
(GetSum a, GetSum b, SumSize a, SumSize b) => GSerializeGet ((:+:) a b) Source # |
Methods gGet :: Get ((a :+: b) a) Source #
(GSerializeGet a, GSerializeGet b) => GSerializeGet ((:*:) a b) Source # |
Methods gGet :: Get ((a :*: b) a) Source #
GSerializeGet a => GSerializeGet (M1 i c a) Source # |
Methods gGet :: Get (M1 i c a a) Source #