-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Read and write values of types that implement Binary
--
-- Read and write values of types that implement Binary
--
-- See module Data.Binary.IO.Lifted.
@package binary-io
@version 0.6.1
-- | Read and write values of types that implement Binary.
module Data.Binary.IO.Lifted
-- | An error that can occur during reading
data ReaderError
-- | Error from the Get operation
ReaderGetError :: !ByteString -> !ByteOffset -> !ByteString -> !String -> ReaderError
-- | Unconsumed part of the byte stream
[readerErrorRemaining] :: ReaderError -> !ByteString
-- | Error location represented as an offset into the input
[readerErrorOffset] :: ReaderError -> !ByteOffset
-- | Input to the Get operation
[readerErrorInput] :: ReaderError -> !ByteString
-- | Error message
[readerErrorMessage] :: ReaderError -> !String
newtype Reader m
Reader :: (forall a. Get a -> m a) -> Reader m
[runReader] :: Reader m -> forall a. Get a -> m a
-- | Create a new reader.
--
-- Inherits properties from newReaderWith.
--
-- Other threads reading from the Handle will interfere with read
-- operations of the Reader. However, the Reader itself is
-- thread-safe and can be utilized concurrently.
--
-- The given Handle will be swiched to binary mode via
-- hSetBinaryMode.
newReader :: (MonadConc m, MonadIO m) => Handle -> m (Reader m)
-- | Create a new Reader using an action that provides the chunks.
--
-- The chunk producers indicates the end of the stream by returning an
-- empty ByteString.
--
-- Reading using the Reader may throw ReaderError.
--
-- The internal position of the Reader is not advanced when it
-- throws an exception during reading. This has the consequence that if
-- you're trying to read with the same faulty Get operation
-- multiple times, you will always receive an exception.
--
-- The Reader is safe to use concurrently.
newReaderWith :: MonadConc m => m ByteString -> m (Reader m)
-- | Transform the underlying functor.
mapReader :: (forall a. m a -> n a) -> Reader m -> Reader n
newtype Writer m
Writer :: (forall a. PutM a -> m a) -> Writer m
[runWriter] :: Writer m -> forall a. PutM a -> m a
-- | Create a writer.
--
-- Other threads writing to the same Handle do not interfere with
-- the resulting Writer. The Writer may be used
-- concurrently.
newWriter :: MonadIO m => Handle -> Writer m
-- | Create a writer using a function that handles the output chunks.
newWriterWith :: Applicative m => (ByteString -> m ()) -> Writer m
-- | Transform the underlying functor.
mapWriter :: (forall x. m x -> n x) -> Writer m -> Writer n
-- | Create a connected pair of Reader and Writer.
--
-- The Reader will automatically end the stream if the
-- Writer goes out of scope.
newPipe :: (MonadConc m, MonadIO m) => m (Reader m, Writer m)
-- | Pair of Reader and Writer
data Duplex m
Duplex :: Writer m -> Reader m -> Duplex m
[duplexWriter] :: Duplex m -> Writer m
[duplexReader] :: Duplex m -> Reader m
-- | Create a new duplex. The Duplex inherits all the properties of
-- Reader and Writer when created with newReader and
-- newWriter.
newDuplex :: (MonadConc m, MonadIO m) => Handle -> m (Duplex m)
-- | Combines newReaderWith and newWriterWith.
newDuplexWith :: MonadConc m => m ByteString -> (ByteString -> m ()) -> m (Duplex m)
-- | Transform the underlying functor.
mapDuplex :: (forall a. m a -> n a) -> Duplex m -> Duplex n
-- | r can execute Get operations in m
class CanGet r m
runGet :: CanGet r m => r -> Get a -> m a
-- | Read something from r. Inherits properties from
-- runGet.
read :: (CanGet r m, Binary a) => r -> m a
-- | Check if there is no more input to consume. This function may block.
-- All properties of runGet apply to this function as well.
isEmpty :: CanGet r m => r -> m Bool
-- | w can execute Put operations in m
class CanPut w m
runPut :: CanPut w m => w -> PutM a -> m a
-- | Write something to w.
write :: (CanPut w m, Binary a) => w -> a -> m ()
instance GHC.Exception.Type.Exception Data.Binary.IO.Lifted.ReaderError
instance GHC.Show.Show Data.Binary.IO.Lifted.ReaderError
instance Data.Binary.IO.Lifted.CanGet (Data.Binary.IO.Lifted.Duplex m) m
instance Data.Binary.IO.Lifted.CanPut (Data.Binary.IO.Lifted.Duplex m) m
instance Data.Binary.IO.Lifted.CanPut (Data.Binary.IO.Lifted.Writer m) m
instance Control.Monad.IO.Class.MonadIO m => Data.Binary.IO.Lifted.CanPut GHC.IO.Handle.Types.Handle m
instance Data.Binary.IO.Lifted.CanGet (Data.Binary.IO.Lifted.Reader m) m
-- | Read and write values of types that implement Binary from and
-- to Handles
--
-- This module homes the unlifted API variant. For proper documentation
-- check out the equally named functions in Data.Binary.IO.Lifted
module Data.Binary.IO
-- | An error that can occur during reading
data ReaderError
-- | Error from the Get operation
ReaderGetError :: !ByteString -> !ByteOffset -> !ByteString -> !String -> ReaderError
-- | Unconsumed part of the byte stream
[readerErrorRemaining] :: ReaderError -> !ByteString
-- | Error location represented as an offset into the input
[readerErrorOffset] :: ReaderError -> !ByteOffset
-- | Input to the Get operation
[readerErrorInput] :: ReaderError -> !ByteString
-- | Error message
[readerErrorMessage] :: ReaderError -> !String
-- | Alias for Reader IO
newtype Reader
Reader :: Reader IO -> Reader
[unReader] :: Reader -> Reader IO
-- | Unlifted version of newReader
newReader :: Handle -> IO Reader
-- | Unlifted version of newReaderWith.
newReaderWith :: IO ByteString -> IO Reader
newtype Writer
Writer :: Writer IO -> Writer
[unWriter] :: Writer -> Writer IO
-- | Unlifted version of newWriter
newWriter :: Handle -> Writer
-- | Unlifted version of newWriterWith
newWriterWith :: (ByteString -> IO ()) -> Writer
-- | Unlifted version of newPipe
newPipe :: IO (Reader, Writer)
data Duplex
Duplex :: !Writer -> !Reader -> Duplex
[duplexWriter] :: Duplex -> !Writer
[duplexReader] :: Duplex -> !Reader
-- | Unlifted version of newDuplex
newDuplex :: Handle -> IO Duplex
-- | Unlifted version of newDuplexWith
newDuplexWith :: IO ByteString -> (ByteString -> IO ()) -> IO Duplex
-- | Alias for CanGet r IO
type CanGet r = CanGet r IO
-- | Unlifted version of runGet
runGet :: CanGet r => r -> Get a -> IO a
-- | Unlifted version of read
read :: (CanGet r, Binary a) => r -> IO a
-- | Unlifted version of isEmpty
isEmpty :: CanGet r => r -> IO Bool
-- | Alias for CanPut w IO
type CanPut w = CanPut w IO
-- | Unlifted version of runPut
runPut :: CanPut w => w -> PutM a -> IO a
-- | Unlifted version of write
write :: (CanPut w, Binary a) => w -> a -> IO ()
instance Data.Binary.IO.Lifted.CanGet Data.Binary.IO.Duplex GHC.Types.IO
instance Data.Binary.IO.Lifted.CanPut Data.Binary.IO.Duplex GHC.Types.IO
instance Data.Binary.IO.Lifted.CanPut Data.Binary.IO.Writer GHC.Types.IO
instance Data.Binary.IO.Lifted.CanGet Data.Binary.IO.Reader GHC.Types.IO