-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Flexible way to ease transmission of binary data.
--   
--   Simple datatype that makes easier to send and receive values in any
--   MonadIO. Inspired by Gregory Crosswhite's 'binary-protocol' package.
@package binary-communicator
@version 1.0.2.1


-- | Binary Communicator
--   
--   This module provides the datatype BinaryCom, which enables you to
--   easily send and receive data to and from a binary source. The
--   transmitted data can be an instance of the <tt>Binary</tt> class, or
--   you can provide your own Put and Get actions to serialize and parse
--   the binary stream.
module Data.BinaryCom

-- | <a>BinaryCom</a> type
data BinaryCom

-- | Creates a <a>BinaryCom</a> from a <a>Handle</a> opened for both
--   reading and writing. Be careful not to use the handle afterwards
binaryCom :: MonadIO m => Handle -> m BinaryCom

-- | Creates a <a>BinaryCom</a> from two <a>Handle</a>s: one for reading,
--   one for writing
binaryCom2H :: MonadIO m => Handle -> Handle -> m BinaryCom

-- | Creates a <a>BinaryCom</a> from a lazy <a>ByteString</a> (for reading)
--   and a <a>Handle</a> (for writing)
binaryComBS :: MonadIO m => ByteString -> Handle -> m BinaryCom

-- | Sends a serializable value through a <a>BinaryCom</a>
send :: (Binary a, MonadIO m) => BinaryCom -> a -> m ()

-- | Runs a continuation, passing it a binary com with auto-flush
--   deactivated. Flushes when the continuation is finished. It permits not
--   to flush at each call to <a>send</a>.
flushAfter :: MonadIO m => BinaryCom -> (BinaryCom -> m ()) -> m ()

-- | Receives a serializable value through a <a>BinaryCom</a>
receive :: (Binary a, MonadIO m) => BinaryCom -> m a

-- | Runs a <a>Put</a> monad and sends its result
sendPut :: MonadIO m => BinaryCom -> Put -> m ()

-- | Receives a value. Runs a <a>Get</a> monad to parse it
receiveGet :: MonadIO m => BinaryCom -> Get a -> m a

-- | A if-then-else, but with the condition as last argument
(+|) :: a -> a -> Bool -> a
