LanguageExt.Streaming

LanguageExt.Streaming Source

Contents

Sub modules

DSL

record Source <A> Source #

A source / stream of values

Parameters

type A

Bound value type

Properties

property Source<A> Empty Source #

A source that never yields a value

Methods

method IO<S> Reduce <S> (S state, Func<S, A, 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 IO<S> Reduce <S> (S state, Reducer<A, 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 IO<S> ReduceAsync <S> (S state, ReducerAsync<A, 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> ReduceAsync <M, S> (S state, ReducerAsync<A, 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 Source<B> Transform <B> (Transducer<A, B> transducer) Source #

Transform with a transducer

Parameters

type B

Target bound value type

param transducer

Transducer to use to transform

returns

Transformed source

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

Functor map

method Source<B> Bind <B> (Func<A, Source<B>> f) Source #

Monad bind

method Source<B> Bind <B> (Func<A, K<Source, B>> f) Source #

Monad bind

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

Filter values. Yielding downstream when true

Parameters

param f

Filter function

returns

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

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

Filter values. Yielding downstream when true

Parameters

param f

Filter function

returns

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

method Source<B> ApplyBack <B> (Source<Func<A, B>> ff) Source #

Applicative apply

method Source<A> Combine (Source<A> rhs) Source #

Concatenate two sources into a single source.

Parameters

param lhs

Left-hand side

param rhs

Right-hand side

returns

Concatenated stream of values

method Source<A> Choose (Source<A> rhs) Source #

The value streams are both merged into a new stream. Values are yielded as they become available.

Parameters

param this

Left-hand side

param rhs

Right-hand side

returns

Merged stream

method Source<(A First, B Second)> Zip <B> (Source<B> second) Source #

Zip two sources into one

Parameters

type B

Bound value-type of the stream to zip with this one

param second

Stream to zip with this one

returns

Stream of values where the items from two streams are paired together

method Source<(A First, B Second, C Third)> Zip <B, C> (Source<B> second, Source<C> third) Source #

Zip three sources into one

Parameters

type B

Bound value-type of the stream to zip with this one

param second

Stream to zip with this one

param third

Stream to zip with this one

returns

Stream of values where the items from two streams are paired together

method Source<(A First, B Second, C Third, D Fourth)> Zip <B, C, D> (Source<B> second, Source<C> third, Source<D> fourth) Source #

Zip three sources into one

Parameters

type B

Bound value-type of the stream to zip with this one

param second

Stream to zip with this one

param third

Stream to zip with this one

param fourth

Stream to zip with this one

returns

Stream of values where the items from two streams are paired together

method Source<A> Skip (int amount) Source #

Skip items in the source

Parameters

param amount

Amount to skip

returns

Transformed source

method Source<A> Take (int amount) Source #

Limit the number of items processed

Parameters

param amount

Amount to take

returns

Transformed source

method Source<S> Fold <S> (Func<S, A, S> Fold, S Init) Source #

Fold the values flowing through. A value is only yielded downstream upon completion of the stream.

Parameters

type S

State type

param Fold

Binary operator

param Init

Initial state

returns

Stream of aggregate state

method Source<S> Fold <S> (Schedule Time, Func<S, A, S> Fold, S Init) Source #

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

Parameters

type S

State type

param Time

Schedule to control the rate of processing

param Fold

Binary operator

param Init

Initial state

returns

Stream of aggregate states

method Source<S> FoldWhile <S> (Func<S, A, S> Fold, Func<S, A, 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 Source<S> FoldUntil <S> (Func<S, A, S> Fold, Func<S, A, 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 Source<S> FoldWhile <S> ( Schedule Time, Func<S, A, S> Fold, Func<S, A, 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 Source<S> FoldUntil <S> ( Schedule Time, Func<S, A, S> Fold, Func<S, A, 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

method ProducerT<A, 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, A, Unit> ToProducer <RT> () Source #

Convert Source to a Producer pipe component

Parameters

returns

Producer

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

Functor map

method Source<C> SelectMany <B, C> (Func<A, Source<B>> bind, Func<A, B, C> project) Source #

Monad bind

Operators

operator + (Source<A> lhs, Source<A> rhs) Source #

Concatenate two sources into a single source.

Parameters

param lhs

Left-hand side

param rhs

Right-hand side

returns

Concatenated stream of values

operator | (Source<A> lhs, Source<A> rhs) 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

operator >> (Source<A> lhs, Source<A> rhs) Source #

Sequentially compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in C#.

Parameters

param lhs

First action to run

param rhs

Second action to run

returns

Result of the second action

operator >> (Source<A> lhs, K<Source, A> rhs) Source #

Sequentially compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in C#.

Parameters

param lhs

First action to run

param rhs

Second action to run

returns

Result of the second action

operator >> (Source<A> lhs, Source<Unit> rhs) Source #

Sequentially compose two actions. The second action is a unit-returning action, so the result of the first action is propagated.

Parameters

param lhs

First action to run

param rhs

Second action to run

returns

Result of the first action

operator >> (Source<A> lhs, K<Source, Unit> rhs) Source #

Sequentially compose two actions. The second action is a unit-returning action, so the result of the first action is propagated.

Parameters

param lhs

First action to run

param rhs

Second action to run

returns

Result of the first action

class SourceExtensions Source #

Methods

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

Downcast

method Source<A> AsSource <A> (this Channel<A> items) Source #

method Source<A> AsSource <A> (this IEnumerable<A> items) Source #

method Source<A> AsSource <A> (this IAsyncEnumerable<A> items) Source #

method IO<Unit> Iter <A> (this K<Source, A> ma) Source #

Force iteration of the stream, yielding a unit M structure.

The expectation is that the stream uses IO for side effects, so this makes them to happen.

method K<M, Unit> Iter <M, A> (this K<Source, A> ma) Source #

where M : MonadIO<M>

Force iteration of the stream, yielding a unit M structure.

The expectation is that the stream uses IO for side effects, so this makes them to happen.

method IO<A> Last <A> (this K<Source, A> ma) Source #

Force iteration of the stream, yielding the last structure processed

method K<M, A> Last <M, A> (this K<Source, A> ma) Source #

where M : MonadIO<M>

Force iteration of the stream, yielding the last structure processed

method IO<Seq<A>> Collect <A> (this K<Source, A> ma) Source #

Force iteration of the stream and collect all the values into a Seq.

method K<M, Seq<A>> Collect <M, A> (this K<Source, A> ma) Source #

where M : MonadIO<M>

Force iteration of the stream and collect all the values into a Seq.

class Source Source #

Methods

method Source<A> empty <A> () Source #

Empty source

This is a 'void' source, it yields zero values.

Parameters

type A

Bound value type

returns

Uninhabited source

method Source<A> pure <A> (A value) Source #

Lift a pure value into the source

This is a singleton/unit source, it yields exactly one value.

Parameters

type A

Bound value type

param value

Value to lift

returns

Singleton source

method Source<A> forever <A> (A value) Source #

Lift a pure value into the source and yield it for infinity

This is an infinite source, it repeatedly yields a value.

Parameters

type A

Bound value type

param value

Value to lift

returns

Infinite source

method Source<A> lift <A> (Channel<A> channel) Source #

Make a System.Threading.Channels.Channel into a source of values

Parameters

type A

Value type

param channel

Channel to lift

returns

Source of values

method Source<A> lift <A> (IEnumerable<A> items) Source #

Make an IEnumerable into a source of values

Parameters

type A

Value type

param items

Enumerable to lift

returns

Source of values

method Source<A> lift <A> (IAsyncEnumerable<A> items) Source #

Make an IEnumerable into a source of values

Parameters

type A

Value type

param items

Enumerable to lift

returns

Source of values

method Source<A> merge <A> (Seq<Source<A>> sources) Source #

Merge sources into a single source

Parameters

type A

Bound value type

param sources

Sources

returns

Source that is the combination of all provided sources

method Source<A> merge <A> (params Source<A>[] sources) Source #

Merge sources into a single source

Parameters

type A

Bound value type

param sources

Sources

returns

Source that is the combination of all provided sources

method Source<(A First, B Second)> zip <A, B> (Source<A> first, Source<B> second) Source #

Zip two sources into one

Parameters

type B

Bound value type of the stream to zip with this one

param second

Stream to zip with this one

returns

Stream of values where the items from two streams are paired together

method Source<(A First, B Second, C Third)> zip <A, B, C> (Source<A> first, Source<B> second, Source<C> third) Source #

Zip three sources into one

Parameters

type B

Bound value type of the stream to zip with this one

param second

Stream to zip with this one

param third

Stream to zip with this one

returns

Stream of values where the items from two streams are paired together

method Source<(A First, B Second, C Third, D Fourth)> zip <A, B, C, D> (Source<A> first, Source<B> second, Source<C> third, Source<D> fourth) Source #

Zip three sources into one

Parameters

type B

Bound value type of the stream to zip with this one

param second

Stream to zip with this one

param third

Stream to zip with this one

param fourth

Stream to zip with this one

returns

Stream of values where the items from two streams are paired together

class Source Source #

Methods

method K<Source, A> Choose <A> (K<Source, A> fa, Func<K<Source, A>> fb) Source #