-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Encode and decode binary streams using the pipes and binary libraries. -- -- Encode and decode binary Pipes streams using the binary -- library. -- -- See the changelog.md file in the source distribution to learn -- about any important changes between version. @package pipes-binary @version 0.4.0.2 -- | pipes utilities for encoding and decoding values as byte -- streams -- -- The tutorial at the bottom of this module illustrates how to use this -- library. -- -- In this module, the following type synonym compatible with the -- lens, lens-family and lens-family-core -- libraries is used but not exported: -- --
-- type Lens' a b = forall f . Functor f => (b -> f b) -> (a -> f a) --module Pipes.Binary -- | Convert a value to a byte stream. -- -- Keep in mind that a single encode value might be split into many -- ByteString chunks, that is, the lenght of the obtained -- Producer might be greater than 1. -- -- Hint: You can easily turn this Producer' into a -- Pipe that encodes Binary instances as they flow -- downstream using: -- --
-- for cat encode :: (Monad m, Binary a) => Pipe a ByteString m r --encode :: (Monad m, Binary a) => a -> Producer' ByteString m () -- | Like encode, except this uses an explicit Put. encodePut :: Monad m => Put -> Producer' ByteString m () -- | Parse a value from a byte stream. decode :: (Monad m, Binary a) => Parser ByteString m (Either DecodingError a) -- | Improper lens that turns a stream of bytes into a stream of -- decoded values. -- -- By improper lens we mean that in practice you can't expect the -- Monad Morphism Laws to be true when using decoded with -- zoom. -- --
-- zoom decoded (return r) /= return r -- zoom decoded (m >>= k) /= zoom m >>= zoom . f --decoded :: (Monad m, Binary a) => Lens' (Producer ByteString m r) (Producer a m (Either (DecodingError, Producer ByteString m r) r)) -- | Like decode, but also returns the length of input consumed in -- order to to decode the value. decodeL :: (Monad m, Binary a) => Parser ByteString m (Either DecodingError (ByteOffset, a)) -- | Like decoded, except this tags each decoded value with the -- length of input consumed in order to decode it. decodedL :: (Monad m, Binary a) => Lens' (Producer ByteString m r) (Producer (ByteOffset, a) m (Either (DecodingError, Producer ByteString m r) r)) -- | Like decode, except this requires an explicit Get -- instead of any Binary instance. decodeGet :: Monad m => Get a -> Parser ByteString m (Either DecodingError a) -- | Like decodeL, except this requires an explicit Get -- instead of any Binary instance. decodeGetL :: Monad m => Get a -> Parser ByteString m (Either DecodingError (ByteOffset, a)) -- | A Get decoding error, as provided by Fail. data DecodingError DecodingError :: {-# UNPACK #-} !ByteOffset -> !String -> DecodingError -- | Number of bytes consumed before the error deConsumed :: DecodingError -> {-# UNPACK #-} !ByteOffset -- | Error message deMessage :: DecodingError -> !String instance Typeable DecodingError instance Show DecodingError instance Read DecodingError instance Eq DecodingError instance Data DecodingError instance Generic DecodingError instance Datatype D1DecodingError instance Constructor C1_0DecodingError instance Selector S1_0_0DecodingError instance Selector S1_0_1DecodingError instance Error DecodingError instance Exception DecodingError