binary: Binary serialization for Haskell values using lazy ByteStrings

[ bsd3, data, library, parsing ] [ Propose Tags ] [ Report a vulnerability ]

Efficient, pure binary serialisation using lazy ByteStrings. Haskell values may be encoded to and form binary formats, written to disk as binary, or set over the network.


[Skip to Readme]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.2, 0.3, 0.4, 0.4.1, 0.4.2, 0.4.3, 0.4.3.1, 0.4.4, 0.4.5, 0.5, 0.5.0.1, 0.5.0.2, 0.5.1.0, 0.5.1.1, 0.6.0.0, 0.6.1.0, 0.6.2.0, 0.6.3.0, 0.6.4.0, 0.7.0.0, 0.7.0.1, 0.7.1.0, 0.7.2.0, 0.7.2.1, 0.7.2.2, 0.7.2.3, 0.7.3.0, 0.7.4.0, 0.7.5.0, 0.7.6.0, 0.7.6.1, 0.8.0.0, 0.8.0.1, 0.8.1.0, 0.8.2.0, 0.8.2.1, 0.8.3.0, 0.8.4.0, 0.8.4.1, 0.8.5.0, 0.8.5.1, 0.8.6.0, 0.8.7.0, 0.8.8.0, 0.8.9.0, 0.8.9.1, 0.8.9.2, 0.9.0.0, 0.10.0.0 (info)
Dependencies base (<4.3) [details]
License BSD-3-Clause
Author Lennart Kolmodin <kolmodin@dtek.chalmers.se>
Maintainer Lennart Kolmodin
Revised Revision 1 made by HerbertValerioRiedel at 2015-01-10T12:43:40Z
Category Data, Parsing
Home page http://www.cse.unsw.edu.au/~dons/binary.html
Uploaded by LennartKolmodin at 2007-03-28T05:51:47Z
Distributions Arch:0.8.9.0, Fedora:0.8.9.1
Reverse Dependencies 1115 direct, 13768 indirect [details]
Downloads 197593 total (640 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for binary-0.3

[back to package description]
  binary: 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.

Building:

    runhaskell Setup.lhs configure
    runhaskell Setup.lhs build
    runhaskell Setup.lhs install

First:
    import Data.Binary

and then write an instance of Binary for the type you wish to serialise.
More information in the haddock documentation.

Deriving:

It is possible to mechanically derive new instances of Binary for your
types, if they support the Data and Typeable classes. A script is
provided in tools/derive. Here's an example of its use.

    $ cd binary 
    $ cd tools/derive 

    $ ghci -fglasgow-exts BinaryDerive.hs

    *BinaryDerive> :l Example.hs 

    *Main> deriveM (undefined :: Drinks)

    instance Binary Main.Drinks where
      put (Beer a) = putWord8 0 >> put a
      put Coffee = putWord8 1
      put Tea = putWord8 2
      put EnergyDrink = putWord8 3
      put Water = putWord8 4
      put Wine = putWord8 5
      put Whisky = putWord8 6
      get = do
        tag_ <- getWord8
        case tag_ of
          0 -> get >>= \a -> return (Beer a)
          1 -> return Coffee
          2 -> return Tea
          3 -> return EnergyDrink
          4 -> return Water
          5 -> return Wine
          6 -> return Whisky

Contributors:

    Lennart Kolmodin
    Duncan Coutts
    Don Stewart
    Spencer Janssen
    David Himmelstrup
    Björn Bringert
    Ross Paterson
    Einar Karttunen
    John Meacham
    Ulf Norell
    Tomasz Zielonka
    Stefan Karrmann
    Bryan O'Sullivan
    Florian Weimer