Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Channel m a = Channel { }
- toChannel :: Channel m ByteString -> Channel m
- fromChannel :: Channel m -> Channel m ByteString
- createPipeConnectedChannels :: IO ( Channel IO ByteString , Channel IO ByteString )
- hoistChannel :: ( forall x. m x -> n x) -> Channel m a -> Channel n a
- isoKleisliChannel :: forall a b m. Monad m => (a -> m b) -> (b -> m a) -> Channel m a -> Channel m b
- fixedInputChannel :: MonadSTM m => [a] -> m ( Channel m a)
- mvarsAsChannel :: MonadSTM m => TMVar m a -> TMVar m a -> Channel m a
- handlesAsChannel :: Handle -> Handle -> Channel IO ByteString
- createConnectedChannels :: MonadSTM m => m ( Channel m a, Channel m a)
- createConnectedBufferedChannels :: forall m a. MonadSTM m => Natural -> m ( Channel m a, Channel m a)
- createConnectedBufferedChannelsSTM :: MonadSTM m => Natural -> STM m ( Channel ( STM m) a, Channel ( STM m) a)
- createPipelineTestChannels :: MonadSTM m => Natural -> m ( Channel m a, Channel m a)
- channelEffect :: forall m a. Monad m => (a -> m ()) -> ( Maybe a -> m ()) -> Channel m a -> Channel m a
- delayChannel :: ( MonadSTM m, MonadTimer m) => DiffTime -> Channel m a -> Channel m a
- loggingChannel :: ( MonadSay m, Show id, Show a) => id -> Channel m a -> Channel m a
Documentation
One end of a duplex channel. It is a reliable, ordered channel of some medium. The medium does not imply message boundaries, it can be just bytes.
Channel | |
|
fromChannel :: Channel m -> Channel m ByteString Source #
createPipeConnectedChannels :: IO ( Channel IO ByteString , Channel IO ByteString ) Source #
Create a local pipe, with both ends in this process, and expose that as
a pair of
Channel
s, one for each end.
This is primarily for testing purposes since it does not allow actual IPC.
hoistChannel :: ( forall x. m x -> n x) -> Channel m a -> Channel n a Source #
isoKleisliChannel :: forall a b m. Monad m => (a -> m b) -> (b -> m a) -> Channel m a -> Channel m b Source #
fixedInputChannel :: MonadSTM m => [a] -> m ( Channel m a) Source #
A
Channel
with a fixed input, and where all output is discarded.
The input is guaranteed to be supplied via
read
with the given chunk
boundaries.
This is only useful for testing. In particular the fixed chunk boundaries can be used to test that framing and other codecs work with any possible chunking.
:: Handle |
Read handle |
-> Handle |
Write handle |
-> Channel IO ByteString |
Make a
Channel
from a pair of IO
Handle
s, one for reading and one
for writing.
The Handles should be open in the appropriate read or write mode, and in binary mode. Writes are flushed after each write, so it is safe to use a buffering mode.
For bidirectional handles it is safe to pass the same handle for both.
createConnectedChannels :: MonadSTM m => m ( Channel m a, Channel m a) Source #
Create a pair of channels that are connected via one-place buffers.
This is primarily useful for testing protocols.
createConnectedBufferedChannels :: forall m a. MonadSTM m => Natural -> m ( Channel m a, Channel m a) Source #
Create a pair of channels that are connected via N-place buffers.
This variant
blocks
when
send
would exceed the maximum buffer size.
Use this variant when you want the environment rather than the
Peer
to
limit the pipelining.
This is primarily useful for testing protocols.
createConnectedBufferedChannelsSTM :: MonadSTM m => Natural -> STM m ( Channel ( STM m) a, Channel ( STM m) a) Source #
As
createConnectedBufferedChannels
, but in
STM
.
TODO: it should return a pair of `Channel m a`.
createPipelineTestChannels :: MonadSTM m => Natural -> m ( Channel m a, Channel m a) Source #
Create a pair of channels that are connected via N-place buffers.
This variant
fails
when
send
would exceed the maximum buffer size.
Use this variant when you want the
PeerPipelined
to limit the pipelining
itself, and you want to check that it does not exceed the expected level of
pipelining.
This is primarily useful for testing protocols.
:: forall m a. Monad m | |
=> (a -> m ()) |
Action before
|
-> ( Maybe a -> m ()) |
Action after
|
-> Channel m a | |
-> Channel m a |
Transform a channel to add an extra action before every send and after every receive.
delayChannel :: ( MonadSTM m, MonadTimer m) => DiffTime -> Channel m a -> Channel m a Source #
Delay a channel on the receiver end.
This is intended for testing, as a crude approximation of network delays. More accurate models along these lines are of course possible.