LanguageExt.Streaming

LanguageExt.Streaming ConduitT

Contents

Sub modules

Internal

class ConduitT <M, A, B> Source #

where M : MonadIO<M>, Monad<M>, Alternative<M>

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

  • A Sink: an input DSL that manipulates values before being placed into the internal queue.
  • An internal queue: usually a System.Threading.Channels.Channel.
  • A Source: an output DSL that manipulates values after being taken from the internal queue.

Both sides of the ConduitT can be manipulated:

The Sink is a Cofunctor and can be mapped using Comap, this transforms values before they get to the channel.

The Source is a monad-transformer, 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 through the Source.

Control of the internal queue is provided by passing a Buffer value to ConduitT.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 ConduitT 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

Properties

property SinkT<M, A> Sink Source #

Access the underlying SinkT for more direct manipulation.

Parameters

returns

property SourceT<M, B> Source Source #

Access the underlying SourceT for more direct manipulation.

Parameters

returns

Methods

method K<M, 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 K<M, Unit> PostM (K<M, A> ma) Source #

Post a value to the Sink

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

Parameters

param ma

Operation to post

returns

IO computation that represents the posting

method K<M, Unit> Complete () Source #

Complete and close the sink

method K<M, Unit> Fail (Error Error) Source #

Complete and close the sink with an Error

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

Iterate the stream, flowing values downstream to the reducer, which aggregates a result value. This is returned lifted.

Note, this is recursive, so M needs to be able to support recursion without blowing the stack. If you have the IO monad in your stack, then this will automatically be the case.

Parameters

type S

State type

param state

Initial state

param reducer

Reducer

returns

Lifted aggregate state

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

Functor map

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

Functor map

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

Contravariant functor map

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

Convert the conduit's Sink to a ConsumerT pipe component

Parameters

returns

ConsumerT

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

Convert the conduit's Source to a ProducerT pipe component

Parameters

returns

ProducerT

method ConduitT<M, A, C> Transform <C> (TransducerM<M, B, C> transducer) Source #

Transform with a transducer

Parameters

param transducer

Transducer to use to transform

returns

Transformed source

method ConduitT<M, X, B> CoTransform <X> (TransducerM<M, X, A> transducer) Source #

Co-transform with a transducer

Parameters

param transducer

Transducer to use to transform

returns

Transformed source

method ConduitT<M, 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 ConduitT<M, 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 ConduitT<M, A, B> Skip (int amount) Source #

Skip items in the source

Parameters

param amount

Number to skip

returns

Transformed source

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

Limit the number of items processed

Parameters

param amount

Number to take

returns

Transformed source

method ConduitT<M, 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 ConduitT<M, 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 ConduitT<M, 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 ConduitT<M, 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 ConduitTExtensions Source #

Methods

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

where M : MonadIO<M>, Monad<M>, Alternative<M>

method Consumer<RT, A, Unit> ToConsumer <RT, A, B> (this ConduitT<Eff<RT>, A, B> conduit) Source #

Convert the conduit's Sink to a Consumer pipe component

Parameters

returns

Consumer

method Producer<RT, B, Unit> ToProducer <RT, A, B> (this ConduitT<Eff<RT>, A, B> conduit) Source #

Convert the conduit's Source to a Producer pipe component

Parameters

returns

Producer

class ConduitT Source #

Methods

method ConduitT<M, A, A> make <M, A> () Source #

where M : MonadIO<M>, Alternative<M>

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 ConduitT<M, A, A> make <M, A> (Buffer<A> buffer) Source #

where M : MonadIO<M>, Alternative<M>

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

method K<M, ConduitT<M, A, A>> makeM <M, A> () Source #

where M : MonadIO<M>, Alternative<M>

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 K<M, ConduitT<M, A, A>> makeM <M, A> (Buffer<A> buffer) Source #

where M : MonadIO<M>, Alternative<M>

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 ConduitT <M, A> Source #

where M : MonadIO<M>, Monad<M>, Alternative<M>

Methods

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

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