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