Permalink
Browse files

Updates!

  • Loading branch information...
1 parent 766fade commit 60145b216f9a9fb263088494eaaa81a26390fa25 @elliottt elliottt committed Sep 15, 2009
View
0 LICENSE 100755 → 100644
No changes.
View
74 README
@@ -1,74 +0,0 @@
-
- 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
View
0 Setup.lhs 100755 → 100644
No changes.
View
27 binary.cabal → binar-e.cabal 100755 → 100644
@@ -1,22 +1,13 @@
-name: binary
-version: 0.5.0.1
+name: binar-e
+version: 0.1
license: BSD3
license-file: LICENSE
-author: Lennart Kolmodin <kolmodin@dtek.chalmers.se>
-maintainer: Lennart Kolmodin, Don Stewart <dons@galois.com>
-homepage: http://code.haskell.org/binary/
-description: 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.
- Serialisation speeds of over 1 G\/sec have been observed,
- so this library should be suitable for high performance
- scenarios.
-synopsis: Binary serialisation for Haskell values using lazy ByteStrings
+author: Galois, Inc.
+maintainer: Galois, Inc.
category: Data, Parsing
stability: provisional
build-type: Simple
-cabal-version: >= 1.2
-tested-with: GHC ==6.4.2, GHC ==6.6.1, GHC ==6.8.0, GHC ==6.10.1
+cabal-version: >= 1.6
extra-source-files: README index.html
flag bytestring-in-base
@@ -44,10 +35,10 @@ library
build-depends: base < 2.0
hs-source-dirs: src
- exposed-modules: Data.Binary,
- Data.Binary.Put,
- Data.Binary.Get,
- Data.Binary.Builder
+ exposed-modules: Data.BinarE,
+ Data.BinarE.Put,
+ Data.BinarE.Get,
+ Data.BinarE.Builder
extensions: CPP,
FlexibleContexts
View
@@ -1,48 +0,0 @@
-\begin{hcarentry}{binary}
-\label{binary}
-\report{Lennart Kolmodin}
-\status{active}
-\participants{Duncan Coutts, Don Stewart, Binary Strike Team}
-\makeheader
-
-The Binary Strike Team is pleased to announce yet a release of a new,
-pure, efficient binary serialisation library.
-
-The `binary' package provides efficient serialisation of Haskell values
-to and from lazy ByteStrings. ByteStrings constructed this way may then
-be written to disk, written to the network, or further processed (e.g.
-stored in memory directly, or compressed in memory with zlib or bzlib).
-
-The binary library has been heavily tuned for performance, particularly for
-writing speed. Throughput of up to 160M/s has been achieved in practice, and
-in general speed is on par or better than NewBinary, with the advantage of a
-pure interface. Efforts are underway to improve performance still further.
-Plans are also taking shape for a parser combinator library on top of
-binary, for bit parsing and foreign structure parsing (e.g. network
-protocols).
-
-Data.Derive~\cref{derive} has support for automatically generating Binary
-instances, allowing to read and write your data structures with little fuzz.
-
-Binary was developed by a team of 8 during the Haskell Hackathon in Oxford
-2007, and since then has about 15 people contributed code and many more
-given feedback and cheerleading on \verb|#haskell|.
-
-The package is cabalized and available through Hackage~\cref{hackagedb}.
-% to editors: ref. to cabal?
-
-\FurtherReading
-\begin{compactitem}
-\item Homepage
-
- \url{http://code.haskell.org/binary/}
-\item Hackage
-
- \url{http://hackage.haskell.org/cgi-bin/hackage-scripts/package/binary}
-\item Development version
-
- \texttt{darcs get --partial}
-
- \url{http://code.haskell.org/binary}
-\end{compactitem}
-\end{hcarentry}
View
@@ -1,161 +0,0 @@
-<?xml version="1.0" encoding="iso-8859-1"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
- <title>Data.Binary - efficient, pure binary serialisation for Haskell</title>
- <link rel="stylesheet" href="http://www.cse.unsw.edu.au/~dons/main.css" type="text/css" />
-</head>
-
-<body xml:lang="en" lang="en">
-
- <div id="content">
-
- <h2>Data.Binary</h2>
-
-<table width="80%" align="center"> <tr><td>
-
- <h3>About</h3>
- <p>
- Data.Binary is a library for high performance binary serialisation
- of <a href="http://haskell.org">Haskell</a> data. It uses the
- <a href="http://www.cse.unsw.edu.au/~dons/fps.html"
- >ByteString</a> library to achieve efficient, lazy reading and
- writing of structures in binary format.
- </p>
-
- <p>
- Chris Eidhof writes on his use of Data.Binary implementing a
- full-text search engine:
- </p>
- <pre>
- "The communication with Sphinx is done using a quite low-level binary
- protocol, but Data.Binary saved the day: it made it very easy for us
- to parse all the binary things. Especially the use of the Get and
- Put monads are a big improvement over the manual reading and keeping
- track of positions, as is done in the PHP/Python clients."
- </pre>
-
- <h3>Example</h3>
- For example, to serialise an interpreter's abstract syntax tree to
- binary format:
-<pre><span class='keyword'>import</span> <span class='conid'>Data</span><span class='varop'>.</span><span class='conid'>Binary</span>
-<span class='keyword'>import</span> <span class='conid'>Control</span><span class='varop'>.</span><span class='conid'>Monad</span>
-<span class='keyword'>import</span> <span class='conid'>Codec</span><span class='varop'>.</span><span class='conid'>Compression</span><span class='varop'>.</span><span class='conid'>GZip</span>
-
-<span class='comment'>-- A Haskell AST structure</span>
-<span class='keyword'>data</span> <span class='conid'>Exp</span> <span class='keyglyph'>=</span> <span class='conid'>IntE</span> <span class='conid'>Int</span>
- <span class='keyglyph'>|</span> <span class='conid'>OpE</span> <span class='conid'>String</span> <span class='conid'>Exp</span> <span class='conid'>Exp</span>
- <span class='keyword'>deriving</span> <span class='conid'>Eq</span>
-
-<span class='comment'>-- An instance of Binary to encode and decode an Exp in binary</span>
-<span class='keyword'>instance</span> <span class='conid'>Binary</span> <span class='conid'>Exp</span> <span class='keyword'>where</span>
- <span class='varid'>put</span> <span class='layout'>(</span><span class='conid'>IntE</span> <span class='varid'>i</span><span class='layout'>)</span> <span class='keyglyph'>=</span> <span class='varid'>put</span> <span class='layout'>(</span><span class='num'>0</span> <span class='keyglyph'>::</span> <span class='conid'>Word8</span><span class='layout'>)</span> <span class='varop'>&gt;&gt;</span> <span class='varid'>put</span> <span class='varid'>i</span>
- <span class='varid'>put</span> <span class='layout'>(</span><span class='conid'>OpE</span> <span class='varid'>s</span> <span class='varid'>e1</span> <span class='varid'>e2</span><span class='layout'>)</span> <span class='keyglyph'>=</span> <span class='varid'>put</span> <span class='layout'>(</span><span class='num'>1</span> <span class='keyglyph'>::</span> <span class='conid'>Word8</span><span class='layout'>)</span> <span class='varop'>&gt;&gt;</span> <span class='varid'>put</span> <span class='varid'>s</span> <span class='varop'>&gt;&gt;</span> <span class='varid'>put</span> <span class='varid'>e1</span> <span class='varop'>&gt;&gt;</span> <span class='varid'>put</span> <span class='varid'>e2</span>
- <span class='varid'>get</span> <span class='keyglyph'>=</span> <span class='keyword'>do</span> <span class='varid'>tag</span> <span class='keyglyph'>&lt;-</span> <span class='varid'>getWord8</span>
- <span class='keyword'>case</span> <span class='varid'>tag</span> <span class='keyword'>of</span>
- <span class='num'>0</span> <span class='keyglyph'>-&gt;</span> <span class='varid'>liftM</span> <span class='conid'>IntE</span> <span class='varid'>get</span>
- <span class='num'>1</span> <span class='keyglyph'>-&gt;</span> <span class='varid'>liftM3</span> <span class='conid'>OpE</span> <span class='varid'>get</span> <span class='varid'>get</span> <span class='varid'>get</span>
-
-<span class='comment'>-- A test expression</span>
-<span class='varid'>e</span> <span class='keyglyph'>=</span> <span class='conid'>OpE</span> <span class='str'>"*"</span> <span class='layout'>(</span><span class='conid'>IntE</span> <span class='num'>7</span><span class='layout'>)</span> <span class='layout'>(</span><span class='conid'>OpE</span> <span class='str'>"/"</span> <span class='layout'>(</span><span class='conid'>IntE</span> <span class='num'>4</span><span class='layout'>)</span> <span class='layout'>(</span><span class='conid'>IntE</span> <span class='num'>2</span><span class='layout'>)</span><span class='layout'>)</span>
-
-<span class='comment'>-- Serialise and compress with gzip, then decompress and deserialise</span>
-<span class='varid'>main</span> <span class='keyglyph'>=</span> <span class='keyword'>do</span>
- <span class='keyword'>let</span> <span class='varid'>t</span> <span class='keyglyph'>=</span> <span class='varid'>compress</span> <span class='layout'>(</span><span class='varid'>encode</span> <span class='varid'>e</span><span class='layout'>)</span>
- <span class='varid'>print</span> <span class='varid'>t</span>
- <span class='keyword'>let</span> <span class='varid'>e'</span> <span class='keyglyph'>=</span> <span class='varid'>decode</span> <span class='layout'>(</span><span class='varid'>decompress</span> <span class='varid'>t</span><span class='layout'>)</span>
- <span class='varid'>print</span> <span class='layout'>(</span><span class='varid'>e</span> <span class='varop'>==</span> <span class='varid'>e'</span><span class='layout'>)</span>
-</pre>
-
- <h3>Download</h3>
-
- <table width="100%"><tr valign="top">
- <td><h4>stable release</h4>
- <table>
- <tr><td>
- <a href="http://hackage.haskell.org/cgi-bin/hackage-scripts/package/binary-0.4.2"
- >binary 0.4.2</a>
- </td><td>(Apr 2008)</td></tr>
-
- <tr><td>
- <a href="http://hackage.haskell.org/cgi-bin/hackage-scripts/package/binary-0.4.1"
- >binary 0.4.1</a>
- </td><td>(Oct 2007)</td></tr>
-
- <tr><td>
- <a href="http://hackage.haskell.org/cgi-bin/hackage-scripts/package/binary-0.4"
- >binary 0.4</a>
- </td><td>(Oct 2007)</td></tr>
-
- <tr><td>
- <a href="http://hackage.haskell.org/cgi-bin/hackage-scripts/package/binary-0.3"
- >binary 0.3</a>
- </td><td>(Mar 2007)</td></tr>
-
- <tr><td>
- <a href="http://hackage.haskell.org/cgi-bin/hackage-scripts/package/binary-0.3"
- >binary 0.2</a>
- </td><td>(Jan 2007)</td></tr>
-
- </table>
- </td>
- <td><h4>development branch</h4>
- <table>
- <tr><td>
- darcs get <a href="http://code.haskell.org/binary"
- >http://code.haskell.org/binary</a>
- </td></tr>
- </table>
- </td> </tr> </table>
-
- <h3>Download</h3>
- <ul>
- <li>
- <a href="http://hackage.haskell.org/packages/archive/binary/0.4.1/doc/html/Data-Binary.html">Documentation</a>
- </li>
- </ul>
-
- <h3>Project Activity</h3>
-
- <center>
- <img src="http://www.cse.unsw.edu.au/~dons/images/commits/community/binary-commits.png"
- alt="binary commit statistics" />
- </center>
-
- <h3>Starring...</h3>
-
- The Binary Strike Force
- <ul>
- <li>Lennart Kolmodin </li>
- <li>Duncan Coutts </li>
- <li>Don Stewart </li>
- <li>Spencer Janssen </li>
- <li>David Himmelstrup </li>
- <li>Björn Bringert </li>
- <li>Ross Paterson </li>
- <li>Einar Karttunen </li>
- <li>John Meacham </li>
- <li>Ulf Norell </li>
- <li>Bryan O'Sullivan </li>
- <li>Tomasz Zielonka </li>
- <li>Florian Weimer </li>
- <li>Judah Jacobson </li>
- </ul>
-
-</td></tr> </table>
-
-<img src="http://xmonad.org/images/HPC.badge.jpg" alt="covered by HPC" />
-<img src="http://xmonad.org/images/cabal.png" alt="built with Cabal" />
-<img src="http://xmonad.org/images/quickcheck.png" alt="tested with QuickCheck" />
-
- </div>
-
-
- <div id="footer">
-Mon Jul 14 11:37:21 PDT 2008
- </div>
-
-</body>
-</html>
View
@@ -1,7 +1,7 @@
{-# LANGUAGE CPP, FlexibleInstances, FlexibleContexts #-}
-----------------------------------------------------------------------------
-- |
--- Module : Data.Binary
+-- Module : Data.BinarE
-- Copyright : Lennart Kolmodin
-- License : BSD3-style (see LICENSE)
--
@@ -25,7 +25,7 @@
--
-----------------------------------------------------------------------------
-module Data.Binary (
+module Data.BinarE (
-- * The Binary class
Binary(..)
@@ -58,8 +58,8 @@ module Data.Binary (
import Data.Word
-import Data.Binary.Put
-import Data.Binary.Get
+import Data.BinarE.Put
+import Data.BinarE.Get
import Control.Monad
import Foreign
@@ -232,7 +232,7 @@ encode = runPut . put
-- | Decode a value from a lazy ByteString, reconstructing the original structure.
--
-decode :: Binary a => ByteString -> a
+decode :: Binary a => ByteString -> Either String a
decode = runGet get
------------------------------------------------------------------------
@@ -267,7 +267,7 @@ encodeFile f v = L.writeFile f (encode v)
-- it is up to the decoding instance to consume the rest of the data,
-- or otherwise finalise the resource.
--
-decodeFile :: Binary a => FilePath -> IO a
+decodeFile :: Binary a => FilePath -> IO (Either String a)
decodeFile f = do
s <- L.readFile f
return $ runGet (do v <- get
Oops, something went wrong.

0 comments on commit 60145b2

Please sign in to comment.