-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Monad to ease implementing a binary network protocol.
--
-- Monad to ease implementing a binary network protocol.
@package binary-protocol
@version 1.0
-- | Monad to ease writing a binary network protocol.
module Control.Monad.BinaryProtocol
type BinaryProtocol = StateT (Handle, Handle, ByteString) IO
-- | Take a BinaryProtocol monad and run it on the given handles for
-- respectively reading and writing. (The two given handles are allowed
-- to be the same if the same handle is used for reading and writing.)
--
-- Note: We run L.hGetContents on the read handle, so don't expect to be
-- able to use it after you have called this function.
runProtocol :: BinaryProtocol a -> Handle -> Handle -> IO a
-- | Read in a value of type a from the connection; a
-- must be an instance of the Binary class.
receive :: Binary a => BinaryProtocol a
-- | Send a value of type a down the connection; a must
-- be an instance of the Binary class.
send :: Binary a => a -> BinaryProtocol ()
-- | Flush buffered send data down the connection.
--
-- Note: You need to make sure to call this between sending requests and
-- receiving responses in order to ensure that the request has actually
-- been sent down the connection; otherwise you might get stuck waiting
-- for a response that will not come.
flush :: BinaryProtocol ()