Copyright | (c) Ivan Lazar Miljenovic |
---|---|

License | MIT |

Maintainer | Ivan.Miljenovic@gmail.com |

Safe Haskell | None |

Language | Haskell2010 |

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.

- spput :: Binary a => SConsumer a PutM e
- spget :: Binary a => SProducer a Get e
- spdecode :: (Binary a, Monad m) => SP ByteString a m String
- spdecodeL :: forall a m. (Binary a, Monad m) => SP ByteString a m String
- spencode :: (Binary a, Functor m) => SP a ByteString m ()
- spencodeL :: Binary a => SP a ByteString m ()
- class Binary t

# Simple encoding/decoding

# 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

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.