Safe Haskell | None |
---|---|
Language | Haskell2010 |
This monad is used to increase the speed of communication between two processes - if there is latency. It works by using the non-deterministic part of the communication protocol to send multiple requests to the output-channel, before processing the responses from the input-channel.
Considering the example
foo = splitRequests [bar, baz] bar = do x <- request (GetSumOf 1 2) liftM Sum request (GetSumOf x 3) baz = liftM Sum request (GetSumOf 4 5)
running foo
in the RequestMonad
:
runRequestMonad inputHandle outputHandle foo
will send both messages GetSumOf 1 2
, GetSumOf 4 5
, without having to wait for the repsonse
to the first request. The last request GetSumOf 3 3
will be send after the response for the
first message has arrived.
- data RequestMonad b
- request :: (Serial a, Serial b) => a -> RequestMonad b
- runRequestMonad :: InputStream ByteString -> OutputStream ByteString -> RequestMonad b -> IO b
- splitRequests :: Monoid a => [RequestMonad a] -> RequestMonad a
Documentation
data RequestMonad b Source
request :: (Serial a, Serial b) => a -> RequestMonad b Source
runRequestMonad :: InputStream ByteString -> OutputStream ByteString -> RequestMonad b -> IO b Source
Run the provided request monad using the given communication channels
splitRequests :: Monoid a => [RequestMonad a] -> RequestMonad a Source
Combine results in the monad non-deterministically (it is required that the monoid is commutative)