Contents
- Mailbox <A, B> (Inbox<A> Inbox, Outbox<B> Outbox)
- Post (A value)
- Read ()
- Complete ()
- Fail (Error Error)
- Map <C> (Func<B, C> f)
- Bind <C> (Func<B, Outbox<C>> f)
- ApplyBack <C> (Outbox<Func<B, C>> ff)
- Contramap <X> (Func<X, A> f)
- ToConsumerT <M> ()
- ToConsumer <RT> ()
- ToProducerT <M> ()
- ToProducer <RT> ()
- Combine (Inbox<A> rhs)
- Combine <X, C> (Func<X, (A Left, C Right)> f, Inbox<C> rhs)
- Combine (Outbox<B> rhs)
- Choose (Outbox<B> rhs)
- + (Inbox<A> lhs, Mailbox<A, B> rhs)
- + (Mailbox<A, B> lhs, Outbox<B> rhs)
- | (Mailbox<A, B> lhs, Outbox<B> rhs)
- Mailbox
record Mailbox <A, B> (Inbox<A> Inbox, Outbox<B> Outbox) Source #
Represents a channel. A channel has:
- An
Inbox
: a queue of values that are its input. - An
Outbox
: a stream of values that are its output.
Both sides of the mailbox can be manipulated:
The Inbox
is a Cofunctor
and can be mapped using Contramap
, this
transforms values before they get to the channel.
The Outbox
is a Monad
, so you can Map
, Bind
, Apply
, in the
usual way to map values on their way out. They manipulate values as theu
leave the channel.
Outbox
values can be both merged (using +
or Combine) and 'chosen' using
|or
Choose`.
Incoming Inbox
values can be split and passed to multiple Inbox
channels using (using +
or `Combine)
ToProducer
and ToConsumer
allows the Mailbox
components to be used
in composed pipe effects.
Parameters
type | A | Input value type |
type | B | Output value type |
param | Inbox | Inbox |
param | Outbox | Outbox |
Methods
method IO<Unit> Post (A value) Source #
Post a value to the inbox
Raises Errors.NoSpaceInInbox
if the inbox is full or closed.
Parameters
param | value | Value to post |
returns | IO computation that represents the posting |
Read value from the outbox
Raises a Errors.OutboxChannelClosed
if the channel is closed or empty
Parameters
returns | First available value from the channel |
method ConsumerT<A, M, Unit> ToConsumerT <M> () Source #
Convert the Inbox
to a ConsumerT
pipe component
Parameters
type | M | Monad to lift (must support |
returns |
|
method Consumer<RT, A, Unit> ToConsumer <RT> () Source #
Convert the Inbox
to a Consumer
pipe component
Parameters
returns |
|
method ProducerT<B, M, Unit> ToProducerT <M> () Source #
Convert Outbox
to a ProducerT
pipe component
Parameters
type | M | Monad to lift (must support |
returns |
|
method Producer<RT, B, Unit> ToProducer <RT> () Source #
Convert Outbox
to a Producer
pipe component
Parameters
returns |
|
method Mailbox<A, B> Combine (Inbox<A> rhs) Source #
Combine two Inboxes: lhs
and rhs
into a single inbox that takes incoming
values and then posts the to the lhs
and rhs
inboxes.
method Mailbox<X, B> Combine <X, C> (Func<X, (A Left, C Right)> f, Inbox<C> rhs) Source #
Combine two Inboxes: lhs
and rhs
into a single inbox that takes incoming
values, maps them to an (A, B)
tuple, and the posts the first and second
elements to the lhs
and rhs
inboxes.
Operators
operator + (Inbox<A> lhs, Mailbox<A, B> rhs) Source #
Combine two inboxes into a single outbox. The values are both merged into a new inbox.
Parameters
param | lhs | Left hand side |
param | rhs | Right hand side |
returns | Merged stream of values |
operator + (Mailbox<A, B> lhs, Outbox<B> rhs) Source #
Combine two outboxes into a single outbox. The value streams are both merged into a new stream. Values are yielded as they become available.
Parameters
param | lhs | Left hand side |
param | rhs | Right hand side |
returns | Merged stream of values |
operator | (Mailbox<A, B> lhs, Outbox<B> rhs) Source #
Choose a value from the first Outbox
to successfully yield
Parameters
param | lhs | Left hand side |
param | rhs | Right hand side |
returns | Value from the |