cereal-0.5.0.0: A binary serialization library

CopyrightLennart Kolmodin, Galois Inc. 2009
LicenseBSD3-style (see LICENSE)
MaintainerTrevor Elliott <trevor@galois.com>
StabilityPortability :
Safe HaskellNone
LanguageHaskell2010

Data.Serialize

Contents

Description

 

Synopsis

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

Instances

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

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.