-- 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.4 -- | 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. -- --
--   encode :: (Monad m, Binary a) => a -> Producer' ByteString m ()
--   
-- -- 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 -> Proxy x' x () ByteString m () -- | Like encode, except this uses an explicit Put. -- --
--   encodePut :: (Monad m) => Put -> Producer' ByteString m ()
--   
encodePut :: Monad m => Put -> Proxy x' x () 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 >>= f)  /= zoom decoded m >>= zoom decoded . 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 -- | A Word is an unsigned integral type, with the same size as -- Int. data Word -- | 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 PutM 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. class Binary t -- | Encode a value in the Put monad. put :: Binary t => t -> Put -- | Decode a value in the Get monad get :: Binary t => Get t -- | Encode a list of values in the Put monad. The default implementation -- may be overridden to be more efficient but must still have the same -- encoding format. putList :: Binary t => [t] -> Put -- | Put merely lifts Builder into a Writer monad, applied to (). type Put = PutM () data Get a -- | An offset, counted in bytes. type ByteOffset = Int64 data Get a -- | Put merely lifts Builder into a Writer monad, applied to (). type Put = PutM () -- | A space-efficient representation of a Word8 vector, supporting -- many efficient operations. -- -- A ByteString contains 8-bit bytes, or by using the operations -- from Data.ByteString.Char8 it can be interpreted as containing -- 8-bit characters. data ByteString -- | A Parser is an action that reads from and writes to a stored -- Producer type Parser a (m :: Type -> Type) r = forall x. () => StateT Producer a m x m r instance GHC.Generics.Generic Pipes.Binary.DecodingError instance Data.Data.Data Pipes.Binary.DecodingError instance GHC.Classes.Eq Pipes.Binary.DecodingError instance GHC.Read.Read Pipes.Binary.DecodingError instance GHC.Show.Show Pipes.Binary.DecodingError instance GHC.Exception.Type.Exception Pipes.Binary.DecodingError instance Control.Monad.Trans.Error.Error Pipes.Binary.DecodingError