Personal tools

Binary IO

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
m (Added link to DealingWithBinaryData)
(Data.Binary: Added a link to System.IO)
(2 intermediate revisions by 2 users not shown)

Latest revision as of 19:03, 23 October 2013

[edit] 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.

For just writing binary data to file, use

   * System.IO

It is a part of the base package, so it comes with GHC.

A tutorial:

   * Serialisation and compression with Data Binary

See also Dealing with binary data

[edit] 2 Other libraries

For very simple serialisation, use

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.