Difference between revisions of "Binary IO"
Jump to navigation
Jump to search
(fixed dead links) |
(→Data.Binary: Added a link to System.IO) |
||
Line 8: | Line 8: | ||
It's very simple to use, and provides a highly efficient, pure interface |
It's very simple to use, and provides a highly efficient, pure interface |
||
to binary serialisation. |
to binary serialisation. |
||
+ | |||
+ | For just writing binary data to file, use |
||
+ | * [http://hackage.haskell.org/package/base-4.6.0.1/docs/System-IO.html#g:21 System.IO] |
||
+ | |||
+ | It is a part of the base package, so it comes with [[GHC]]. |
||
A tutorial: |
A tutorial: |
||
+ | * [[Serialisation and compression with Data Binary]] |
||
− | * [[Serialisation_and_compression_with_Data_Binary]] |
||
− | See also [[ |
+ | See also [[Dealing with binary data]] |
== Other libraries == |
== Other libraries == |
Latest revision as of 19:03, 23 October 2013
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
Other libraries
- JeremyShaw's update of HalDaume's NewBinary package (Cabalized): http://www.n-heptane.com/nhlab/repos/NewBinary
- Data.ByteString (Cabalised) also provides byte level operations, and is used in some applications for binary IO
- SerTH, the TH version (sort of) of NewBinary.
- PeterSimons's BlockIO package (Cabalized): http://cryp.to/blockio/
- JohnGoerzen's MissingH package (Cabalized): http://quux.org/devel/missingh
- SimonMarlow's experimental NewIO package: http://www.haskell.org/~simonmar/new-io.tar.gz (documentation at http://www.haskell.org/~simonmar/io/)
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.