LanguageExt.Streaming

LanguageExt.Streaming Conduit

Contents

Sub modules

Internal

class Conduit <A, B> Source #

Represents a channel with an internal queue. A channel has:

  • A sink: an input transducer that manipulates values before being placed into the internal queue.
  • A buffer: System.Threading.Channels.Channel.
  • A source: an output transducer that manipulates values after being taken from the internal queue.

Both sides of the conduit can be manipulated:

The sink is a co-functor and can be mapped using Comap or CoTransform, these transform values before they get to the conduit's buffer.

The source is a functor, so you can Map or Transform in the usual way to map values on their way out of the buffer.

Control of the internal buffer is provided by passing a Buffer value to Conduit.make. This allows you to set various parameters for the internal queue, such as the maximum number of items to hold in the queue, and what strategy to use when the queue is full. The default is Buffer.Unbounded.

ToProducer and ToConsumer enable the Conduit components to be used in composed pipe effects.

Parameters

type A

Input value type

type B

Output value type

Properties

property Sink<A> Sink Source #

Access the underlying Sink for more direct manipulation.

Parameters

returns

property Source<B> Source Source #

Access the underlying Source for more direct manipulation.

Parameters

returns

Methods

method IO<Unit> Post (A value) Source #

Post a value to the Sink

Raises Errors.SinkFull if the Sink is full or closed.

Parameters

param value

Value to post

returns

IO computation that represents the posting

method IO<Unit> Complete () Source #

Complete and close the Sink

method IO<Unit> Fail (Error Error) Source #

Complete and close the Sink with an Error

method IO<S> Reduce <S> (S state, ReducerAsync<B, S> reducer) Source #

Iterate the stream, flowing values downstream to the reducer, which aggregates a result value.

Parameters

type S

State type

param state

State to reduce

param reducer

Reducer

returns

Reduced state

method K<M, S> Reduce <M, S> (S state, ReducerAsync<B, S> reducer) Source #

where M : MonadIO<M>

Iterate the stream, flowing values downstream to the reducer, which aggregates a result value.

Parameters

type S

State type

param state

State to reduce

param reducer

Reducer

returns

Reduced state

method Conduit<A, C> Map <C> (Func<B, C> f) Source #

Functor map

method Conduit<A, C> Select <C> (Func<B, C> f) Source #

Functor map

method Conduit<A, C> Transform <C> (Transducer<B, C> transducer) Source #

Transform with a transducer

Parameters

param transducer

Transducer to use to transform

returns

Transformed source

method Conduit<X, B> Comap <X> (Func<X, A> f) Source #

Contravariant functor map

method Conduit<X, B> CoTransform <X> (Transducer<X, A> transducer) Source #

Co-transform with a transducer

Parameters

param transducer

Transducer to use to transform

returns

Transformed source

method ConsumerT<A, M, Unit> ToConsumerT <M> () Source #

where M : MonadIO<M>

Convert the Sink to a ConsumerT pipe component

Parameters

type M

Monad to lift (must support IO)

returns

ConsumerT

method Consumer<RT, A, Unit> ToConsumer <RT> () Source #

Convert the Sink to a Consumer pipe component

Parameters

returns

Consumer

method ProducerT<B, M, Unit> ToProducerT <M> () Source #

where M : MonadIO<M>

Convert Source to a ProducerT pipe component

Parameters

type M

Monad to lift (must support IO)

returns

ProducerT

method Producer<RT, B, Unit> ToProducer <RT> () Source #

Convert Source to a Producer pipe component

Parameters

returns

Producer

method Conduit<A, B> Where (Func<B, bool> f) Source #

Filter values. Yielding downstream when true

Parameters

param f

Filter function

returns

SourceT where the only values yield are those that pass the predicate

method Conduit<A, B> Filter (Func<B, bool> f) Source #

Filter values. Yielding downstream when true

Parameters

param f

Filter function

returns

SourceT where the only values yield are those that pass the predicate

method Conduit<A, B> Skip (int amount) Source #

Skip items in the source

Parameters

param amount

Amount to skip

returns

Transformed source

method Conduit<A, B> Take (int amount) Source #

Limit the number of items processed

Parameters

param amount

Number to take

returns

Transformed source

method Conduit<A, S> FoldWhile <S> (Func<S, B, S> Fold, Func<S, B, bool> Pred, S Init) Source #

Fold the values flowing through. Values are yielded downstream when either the predicate returns false, or the source completes.

Parameters

type S

State type

param Fold

Binary operator

param Pred

Predicate

param Init

Initial state

returns

Stream of aggregate states

method Conduit<A, S> FoldUntil <S> (Func<S, B, S> Fold, Func<S, B, bool> Pred, S Init) Source #

Fold the values flowing through. Values are yielded downstream when either the predicate returns true, or the source completes.

Parameters

type S

State type

param Fold

Binary operator

param Pred

Predicate

param Init

Initial state

returns

Stream of aggregate states

method Conduit<A, S> FoldWhile <S> ( Schedule Time, Func<S, B, S> Fold, Func<S, B, bool> Pred, S Init) Source #

Fold the values flowing through. Values are yielded downstream when either the schedule expires, the predicate returns false, or the source completes.

Parameters

type S

State type

param Time

Schedule to control the rate of processing

param Fold

Binary operator

param Pred

Predicate

param Init

Initial state

returns

Stream of aggregate states

method Conduit<A, S> FoldUntil <S> ( Schedule Time, Func<S, B, S> Fold, Func<S, B, bool> Pred, S Init) Source #

Fold the values flowing through. Values are yielded downstream when either the schedule expires, the predicate returns true, or the source completes.

Parameters

type S
param Time

Schedule to control the rate of processing

param Fold

Binary operator

param Pred

Predicate

param Init

Initial state

returns

Stream of aggregate states

class ConduitExtensions Source #

Methods

method Conduit<A, B> As <A, B> (this K<Conduit<A>, B> ma) Source #

class Conduit Source #

Methods

method Conduit<A, A> make <A> () Source #

Create a new unbounded Conduit

Parameters

type A

Value type

param label

Label for debugging purposes

returns

Constructed Conduit with an Sink and an Source

method Conduit<A, A> make <A> (Buffer<A> buffer) Source #

Create a new Conduit with the buffer settings provided

Parameters

type A

Value type

param buffer

Buffer settings

param label

Label for debugging purposes

returns

Constructed Conduit with an Sink and an Source

class Conduit <A> Source #

Methods

method K<Conduit<A>, X> Comap <X, B> (Func<X, B> f, K<Conduit<A>, B> fb) Source #

method K<Conduit<A>, C> Map <B, C> (Func<B, C> f, K<Conduit<A>, B> ma) Source #