MyGit

haskell/binary

Fork: 65 Star: 106 (更新于 2024-11-03 14:35:40)

license: NOASSERTION

Language: Haskell .

Efficient, pure binary serialisation using ByteStrings in Haskell.

GitHub网址

binary package

Hackage version Stackage version Build Status

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 moderately 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.

$ git clone git@github.com:kolmodin/binary.git
$ cd binary
$ cabal update
$ cabal configure --enable-tests --enable-benchmarks
$ cabal build

Run the test suite.

$ cabal test

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.

{-# LANGUAGE DeriveGeneric #-}

import Data.Binary
import GHC.Generics (Generic)

data Foo = Foo deriving (Generic)

-- GHC will automatically fill out the instance
instance Binary Foo

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
  • Bas van Dijk
  • Florian Weimer

For a full list of contributors, see here.

最近版本更新:(数据更新于 2024-08-29 17:21:39)

haskell/binary同语言 Haskell最近更新仓库

2024-08-22 12:09:58 ivanperez-keera/dunai

2024-05-25 09:59:31 reflex-frp/reflex-vty

2023-11-11 06:13:10 clash-lang/clash-compiler

2022-08-13 21:55:30 HeinrichApfelmus/reactive-banana

2016-10-03 14:00:16 z0w0/helm

1970-01-01 00:00:00 haskellweekly/reveille