quiver-binary-0.1.1.0: Binary serialisation support for Quivers

Copyright(c) Ivan Lazar Miljenovic
LicenseMIT
MaintainerIvan.Miljenovic@gmail.com
Safe HaskellNone
LanguageHaskell2010

Control.Quiver.Binary

Contents

Description

This module provides functions for encoding/decoding values within a Quiver.

For any I/O operations, use the functions provided by the quiver-bytestring package.

Synopsis

Simple encoding/decoding

spput :: Binary a => SConsumer a PutM e Source

Encode all values.

spget :: Binary a => SProducer a Get e Source

Decode all values.

Conversions to/from ByteStrings

spdecode :: (Binary a, Monad m) => SP ByteString a m String Source

Decode all values from the provided stream of strict ByteStrings. Note that the error message does not return the ByteOffset from the Decoder as it will probably not match the actual location of the source ByteString.

spdecodeL :: forall a m. (Binary a, Monad m) => SP ByteString a m String Source

Decode all values from the provided stream of lazy ByteStrings. Note that the error message does not return the ByteOffset from the Decoder as it will probably not match the actual location of the source ByteString.

spencode :: (Binary a, Functor m) => SP a ByteString m () Source

Encode all values to a stream of strict ByteStrings.

spencodeL :: Binary a => SP a ByteString m () Source

Encode all values to a stream of lazy ByteStrings.

Re-exports

class Binary t

The Binary class provides put and get, methods to encode and decode a Haskell value to a lazy ByteString. It mirrors the Read and Show classes for textual representation of Haskell types, and is suitable for serialising Haskell values to disk, over the network.

For decoding and generating simple external binary formats (e.g. C structures), Binary may be used, but in general is not suitable for complex protocols. Instead use the Put and Get primitives directly.

Instances of Binary should satisfy the following property:

decode . encode == id

That is, the get and put methods should be the inverse of each other. A range of instances are provided for basic Haskell types.

Instances

Binary Bool 
Binary Char 
Binary Double 
Binary Float 
Binary Int 
Binary Int8 
Binary Int16 
Binary Int32 
Binary Int64 
Binary Integer 
Binary Ordering 
Binary Word 
Binary Word8 
Binary Word16 
Binary Word32 
Binary Word64 
Binary () 
Binary Natural 
Binary ByteString 
Binary ByteString 
Binary IntSet 
Binary a => Binary [a] 
(Binary a, Integral a) => Binary (Ratio a) 
Binary a => Binary (Maybe a) 
Binary e => Binary (IntMap e) 
Binary a => Binary (Set a) 
Binary e => Binary (Tree e) 
Binary e => Binary (Seq e) 
(Binary a, Binary b) => Binary (Either a b) 
(Binary a, Binary b) => Binary (a, b) 
(Binary i, Ix i, Binary e, IArray UArray e) => Binary (UArray i e) 
(Binary i, Ix i, Binary e) => Binary (Array i e) 
(Binary k, Binary e) => Binary (Map k e) 
(Binary a, Binary b, Binary c) => Binary (a, b, c) 
(Binary a, Binary b, Binary c, Binary d) => Binary (a, b, c, d) 
(Binary a, Binary b, Binary c, Binary d, Binary e) => Binary (a, b, c, d, e) 
(Binary a, Binary b, Binary c, Binary d, Binary e, Binary f) => Binary (a, b, c, d, e, f) 
(Binary a, Binary b, Binary c, Binary d, Binary e, Binary f, Binary g) => Binary (a, b, c, d, e, f, g) 
(Binary a, Binary b, Binary c, Binary d, Binary e, Binary f, Binary g, Binary h) => Binary (a, b, c, d, e, f, g, h) 
(Binary a, Binary b, Binary c, Binary d, Binary e, Binary f, Binary g, Binary h, Binary i) => Binary (a, b, c, d, e, f, g, h, i) 
(Binary a, Binary b, Binary c, Binary d, Binary e, Binary f, Binary g, Binary h, Binary i, Binary j) => Binary (a, b, c, d, e, f, g, h, i, j)