| Safe Haskell | None |
|---|
Pipes.Binary
Contents
Description
This module exports facilities that allow you to encode and decode Pipes
streams of binary values. It builds on top of the binary, pipes and
pipes-parse libraries, and assumes you know how to use those libraries.
- encode :: (Monad m, Binary x) => x -> Producer' ByteString m ()
- decode :: (Monad m, Binary b) => StateT (Producer ByteString m r) m (Either DecodingError (ByteOffset, b))
- decodeMany :: (Monad m, Binary b) => Producer ByteString m r -> Producer' (ByteOffset, b) m (Either (DecodingError, Producer ByteString m r) r)
- decodeGet :: Monad m => Get b -> StateT (Producer ByteString m r) m (Either DecodingError (ByteOffset, b))
- decodeGetMany :: Monad m => Get b -> Producer ByteString m r -> Producer' (ByteOffset, b) m (Either (DecodingError, Producer ByteString m r) r)
- encodePut :: Monad m => Put -> Producer' ByteString m ()
- data DecodingError = DecodingError {}
- isEndOfBytes :: Monad m => StateT (Producer ByteString m r) m Bool
- module Data.Binary.Get
Binary instances
encode :: (Monad m, Binary x) => x -> Producer' ByteString m ()Source
Encodes the given Binary instance and sends it downstream in
ByteString chunks.
Arguments
| :: (Monad m, Binary b) | |
| => StateT (Producer ByteString m r) m (Either DecodingError (ByteOffset, b)) |
Try to decode leading output from the underlying Producer into a
Binary instance, returning either a DecodingError on failure, or a
pair with the decoded entity together with the number of bytes consumed in
order to produce it.
Do not use this function if isEndOfBytes returns True, otherwise you
may get unexpected decoding errors.
Arguments
| :: (Monad m, Binary b) | |
| => Producer ByteString m r | Producer from which to draw input. |
| -> Producer' (ByteOffset, b) m (Either (DecodingError, Producer ByteString m r) r) |
Continuously decode output from the given Producer into a Binary
instance, sending downstream pairs of each successfully decoded entity
together with the number of bytes consumed in order to produce it.
This Producer runs until it either runs out of input or a decoding
failure occurs, in which case it returns Left with a DecodingError and
a Producer with any leftovers. You can use errorP to turn the Either
return value into an ErrorT monad transformer.
Get monad
Arguments
| :: Monad m | |
| => Get b | |
| -> StateT (Producer ByteString m r) m (Either DecodingError (ByteOffset, b)) |
Arguments
| :: Monad m | |
| => Get b | |
| -> Producer ByteString m r | Producer from which to draw input. |
| -> Producer' (ByteOffset, b) m (Either (DecodingError, Producer ByteString m r) r) |
Like decodeMany, except it takes an explicit Get monad.
Put monad
Types
data DecodingError Source
Constructors
| DecodingError | |
Fields
| |
Exports
The following types are re-exported on this module for your convenience:
- From Data.Binary
-
Binary. - From Data.Binary.Get
-
Get,ByteOffset. - From Data.Binary.Put
-
Put.
isEndOfBytes :: Monad m => StateT (Producer ByteString m r) m BoolSource
module Data.Binary.Get