Personal tools

Binary IO

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
m (link to serTH in internet archive)
(fixed dead links)
Line 18: Line 18:
   
 
* JeremyShaw's update of HalDaume's NewBinary package (Cabalized): http://www.n-heptane.com/nhlab/repos/NewBinary
 
* JeremyShaw's update of HalDaume's NewBinary package (Cabalized): http://www.n-heptane.com/nhlab/repos/NewBinary
* [http://www.cse.unsw.edu.au/~dons/fps.html Data.ByteString] (Cabalised) also provides byte level operations, and is used in some applications for binary IO
+
* [http://hackage.haskell.org/package/bytestring Data.ByteString] (Cabalised) also provides byte level operations, and is used in some applications for binary IO
* [http://www.cs.helsinki.fi/u/ekarttun/SerTH/ SerTH], [http://web.archive.org/web/20080123105519/http://www.cs.helsinki.fi/u/ekarttun/SerTH/ archived page] the TH version (sort of) of NewBinary.
+
* [http://web.archive.org/web/20080123105519/http://www.cs.helsinki.fi/u/ekarttun/SerTH/ SerTH], the TH version (sort of) of NewBinary.
 
* PeterSimons's BlockIO package (Cabalized): http://cryp.to/blockio/
 
* PeterSimons's BlockIO package (Cabalized): http://cryp.to/blockio/
 
* JohnGoerzen's MissingH package (Cabalized): http://quux.org/devel/missingh
 
* JohnGoerzen's MissingH package (Cabalized): http://quux.org/devel/missingh

Revision as of 21:33, 29 October 2011

1 Data.Binary

There are a number of binary I/O libraries available for Haskell. The best to use is the new, semi-standard Data.Binary library:

   * Data.Binary

It's very simple to use, and provides a highly efficient, pure interface to binary serialisation.

A tutorial:

   * Serialisation_and_compression_with_Data_Binary

See also DealingWithBinaryData

2 Other libraries

For very simple serialisation, use
read
and
show
.

If you have simple binary IO requirements, then Data.ByteString might be easiest -- you get a List-like interface to packed byte arrays (interface documented here). For more complex serialisation, Data.Binary would be preferred.