Efficient, pure binary serialisation using lazy ByteStrings.
Haskell values may be encoded to and from binary formats,
written to disk as binary, or sent over the network.
The format used can be automatically generated, or
you can choose to implement a custom format if needed.
Serialisation speeds of over 1 G/sec have been observed,
so this library should be suitable for high performance
scenarios.

Maintainer's Corner

Readme for binary-0.8.5.0

binary package

Efficient, pure binary serialisation using lazy ByteStrings.

The binary package provides Data.Binary, containing the Binary class,
and associated methods, for serialising values to and from lazy
ByteStrings.
A key feature of binary is that the interface is both pure, and efficient.
The binary package is portable to GHC and Hugs.

Installing binary from Hackage

binary is part of The Glasgow Haskell Compiler (GHC) and therefore if you
have either GHC or The Haskell Platform
installed, you already have binary.

More recent versions of binary than you might have installed may be
available. You can use cabal-install to install a later version from
Hackage.

$ cabal update
$ cabal install binary

Building binary

binary comes with both a test suite and a set of benchmarks.
While developing, you probably want to enable both.
Here's how to get the latest version of the repository, configure and build.

Using binary

First:

import Data.Binary

and then write an instance of Binary for the type you wish to serialise.
An example doing exactly this can be found in the Data.Binary module.
You can also use the Data.Binary.Builder module to efficiently build
lazy bytestrings using the Builder monoid. Or, alternatively, the
Data.Binary.Get and Data.Binary.Put to serialize/deserialize using
the Get and Put monads.

More information in the haddock documentation.

Deriving binary instances using GHC's Generic

Beginning with GHC 7.2, it is possible to use binary serialization without
writing any instance boilerplate code.