LanguageExt.Core

LanguageExt.Core Effects Pipes Producer

Contents

record Producer <OUT, M, A> Source #

where M : Monad<M>

Producers can only yield

  Upstream | Downstream
      +---------+
      |         |
Void <==       <== Unit
      |         |
Unit ==>       ==> OUT
      |    |    |
      +----|----+
           |
           A

Fields

field Proxy<Void, Unit, Unit, OUT, M, A> Value Source #

Constructors

constructor Producer (Proxy<Void, Unit, Unit, OUT, M, A> value) Source #

Constructor

Parameters

param value

Correctly shaped Proxy that represents a Producer

Methods

method Proxy<Void, Unit, Unit, OUT, M, A> ToProxy () Source #

Calling this will effectively cast the sub-type to the base.

This type wraps up a Proxy for convenience, and so it's a Proxy proxy. So calling this method isn't exactly the same as a cast operation, as it unwraps the Proxy from within. It has the same effect however, and removes a level of indirection

Parameters

returns

A general Proxy type from a more specialised type

method Proxy<Void, Unit, Unit, OUT, M, S> Bind <S> ( Func<A, Proxy<Void, Unit, Unit, OUT, M, S>> f) Source #

Monadic bind operation, for chaining Proxy computations together.

Parameters

type B

The mapped bound value type

param f

The bind function

returns

A new Proxy that represents the composition of this Proxy and the result of the bind operation

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

Monadic bind operation, for chaining Proxy computations together.

Parameters

type B

The mapped bound value type

param f

The bind function

returns

A new Proxy that represents the composition of this Proxy and the result of the bind operation

method Producer<OUT, M, B> Bind <B> (Func<A, IO<B>> f) Source #

Monadic bind operation, for chaining Proxy computations together.

Parameters

type B

The mapped bound value type

param f

The bind function

returns

A new Proxy that represents the composition of this Proxy and the result of the bind operation

method Proxy<Void, Unit, Unit, OUT, M, B> Map <B> (Func<A, B> f) Source #

Lifts a pure function into the Proxy domain, causing it to map the bound value within

Parameters

type B

The mapped bound value type

param f

The map function

returns

A new Proxy that represents the composition of this Proxy and the result of the map operation

method Proxy<Void, Unit, Unit, OUT, M, B> MapM <B> (Func<K<M, A>, K<M, B>> f) Source #

Map the lifted monad

Parameters

type B

The mapped bound value type

param f

The map function

returns

A new Proxy that represents the composition of this Proxy and the result of the map operation

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

Monadic bind operation, for chaining Proxy computations together.

Parameters

type B

The mapped bound value type

param f

The bind function

returns

A new Proxy that represents the composition of this Proxy and the result of the bind operation

method Producer<OUT, M, B> SelectMany <B> (Func<A, Producer<OUT, M, B>> f) Source #

Monadic bind operation, for chaining Proxy computations together.

Parameters

type B

The mapped bound value type

param f

The bind function

returns

A new Proxy that represents the composition of this Proxy and the result of the bind operation

method Producer<OUT, M, C> SelectMany <B, C> (Func<A, Producer<OUT, M, B>> f, Func<A, B, C> project) Source #

Monadic bind operation, for chaining Proxy computations together.

Parameters

type B

The mapped bound value type

param f

The bind function

returns

A new Proxy that represents the composition of this Proxy and the result of the bind operation

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

Lifts a pure function into the Proxy domain, causing it to map the bound value within

Parameters

type B

The mapped bound value type

param f

The map function

returns

A new Proxy that represents the composition of this Proxy and the result of the map operation

method Proxy<Void, Unit, C1, C, M, A> For <C1, C> (Func<OUT, Proxy<Void, Unit, C1, C, M, Unit>> body) Source #

For(body) loops over the Proxy p replacing each yield with body

Parameters

param body

Any yield found in the Proxy will be replaced with this function. It will be composed so that the value yielded will be passed to the argument of the function. That returns a Proxy to continue the processing of the computation

returns

A new Proxy that represents the composition of this Proxy and the function provided

method Proxy<Void, Unit, Unit, OUT, M, B> Action <B> (Proxy<Void, Unit, Unit, OUT, M, B> r) Source #

Applicative action

Invokes this Proxy, then the Proxy r

Parameters

param r

Proxy to run after this one

method Proxy<UOutA, AUInA, Unit, OUT, M, A> PairEachRequestWithRespond <UOutA, AUInA> ( Func<Void, Proxy<UOutA, AUInA, Void, Unit, M, A>> lhs) Source #

Used by the various composition functions and when composing proxies with the | operator. You usually wouldn't need to call this directly, instead either pipe them using | or call Proxy.compose(lhs, rhs)

(f +>> p) pairs each 'request' in this with a 'respond' in lhs.

method Proxy<UOutA, AUInA, Unit, OUT, M, A> ReplaceRequest <UOutA, AUInA> ( Func<Void, Proxy<UOutA, AUInA, Unit, OUT, M, Unit>> lhs) Source #

Used by the various composition functions and when composing proxies with the | operator. You usually wouldn't need to call this directly, instead either pipe them using | or call Proxy.compose(lhs, rhs)

method Proxy<Void, Unit, DInC, DOutC, M, A> PairEachRespondWithRequest <DInC, DOutC> ( Func<OUT, Proxy<Unit, OUT, DInC, DOutC, M, A>> rhs) Source #

Used by the various composition functions and when composing proxies with the | operator. You usually wouldn't need to call this directly, instead either pipe them using | or call Proxy.compose(lhs, rhs)

method Proxy<Void, Unit, DInC, DOutC, M, A> ReplaceRespond <DInC, DOutC> ( Func<OUT, Proxy<Void, Unit, DInC, DOutC, M, Unit>> rhs) Source #

Used by the various composition functions and when composing proxies with the | operator. You usually wouldn't need to call this directly, instead either pipe them using | or call Proxy.compose(lhs, rhs)

method Proxy<OUT, Unit, Unit, Void, M, A> Reflect () Source #

Reverse the arrows of the Proxy to find its dual.

Parameters

returns

The dual of this

method Proxy<Void, Unit, Unit, OUT, M, A> Observe () Source #

Observe(lift (Pure(r))) = Observe(Pure(r))
Observe(lift (m.Bind(f))) = Observe(lift(m.Bind(x => lift(f(x)))))

This correctness comes at a small cost to performance, so use this function sparingly. This function is a convenience for low-level pipes implementers. You do not need to use observe if you stick to the safe API.

method void Deconstruct (out Proxy<Void, Unit, Unit, OUT, M, A> value) Source #

method Producer<OUT, M, B> SelectMany <B> (Func<A, Producer<OUT, B>> bind) Source #

Monadic bind operation, for chaining Proxy computations together.

Parameters

type B

The mapped bound value type

param f

The bind function

returns

A new Proxy that represents the composition of this Proxy and the result of the bind operation

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

Monadic bind operation, for chaining Proxy computations together.

Parameters

type B

The mapped bound value type

param f

The bind function

returns

A new Proxy that represents the composition of this Proxy and the result of the bind operation

method Producer<OUT, M, C> SelectMany <B, C> (Func<A, K<M, B>> bind, Func<A, B, C> project) Source #

Monadic bind operation, for chaining Proxy computations together.

Parameters

type B

The mapped bound value type

param f

The bind function

returns

A new Proxy that represents the composition of this Proxy and the result of the bind operation

method string ToString () Source #

Operators

operator | (Producer<OUT, M, A> p1, Consumer<OUT, M, A> p2) Source #

Compose a Producer and a Consumer together into an Effect.

Parameters

param p1

Producer

param p2

Consumer

returns

Effect

operator | (Producer<OUT, M, A> p1, Consumer<OUT, A> p2) Source #

Compose a Producer and a Consumer together into an Effect.

Parameters

param p1

Producer

param p2

Consumer

returns

Effect

operator & ( Producer<OUT, M, A> lhs, Producer<OUT, M, A> rhs) Source #

Chain one producer's set of yields after another

class Producer Source #

Producers can only yield

  Upstream | Downstream
      +---------+
      |         |
Void <==       <== Unit
      |         |
Unit ==>       ==> OUT
      |    |    |
      +----|----+
           |
           A

Methods

method Producer<OUT, M, R> Pure <OUT, M, R> (R value) Source #

where M : Monad<M>

Monad return / pure

method Producer<OUT, M, Unit> yield <OUT, M> (OUT value) Source #

where M : Monad<M>

Send a value downstream (whilst in a producer)

This is the simpler version (fewer generic arguments required) of yield that works for producers.

method Producer<X, M, Unit> yieldAll <M, X> (IEnumerable<X> xs) Source #

where M : Monad<M>

method Producer<X, M, Unit> yieldAll <M, X> (IAsyncEnumerable<X> xs) Source #

where M : Monad<M>

method Producer<X, M, Unit> yieldAll <M, X> (IObservable<X> xs) Source #

where M : Monad<M>

method Producer<A, M, Unit> repeatM <M, A> (K<M, A> ma) Source #

where M : Monad<M>

Repeat a monadic action indefinitely, yielding each result

method Producer<OUT, M, R> lift <OUT, M, R> (K<M, R> ma) Source #

where M : Monad<M>

Lift the IO monad into the Producer monad transformer (a specialism of the Proxy monad transformer)

method Producer<OUT, M, R> liftIO <OUT, M, R> (IO<R> ma) Source #

where M : Monad<M>

Lift the IO monad into the Producer monad transformer (a specialism of the Proxy monad transformer)

method Producer<S, M, Unit> FoldUntil <S, M, A> ( this Producer<S, M, A> ma, S Initial, Func<S, A, S> Fold, Func<A, bool> UntilValue) Source #

where M : Monad<M>

Folds values coming down-stream, when the predicate returns true the folded value is yielded

Parameters

param Initial

Initial state

param Fold

Fold operation

param UntilValue

Predicate

returns

A pipe that folds

method Producer<S, M, Unit> FoldWhile <S, M, A> ( this Producer<S, M, A> ma, S Initial, Func<S, A, S> Fold, Func<A, bool> WhileValue) Source #

where M : Monad<M>

Folds values coming down-stream, when the predicate returns true the folded value is yielded

Parameters

param Initial

Initial state

param Fold

Fold operation

param UntilValue

Predicate

returns

A pipe that folds

method Producer<S, M, Unit> FoldUntil <S, M, A> ( this Producer<S, M, A> ma, S Initial, Func<S, A, S> Fold, Func<S, bool> UntilState) Source #

where M : Monad<M>

Folds values coming down-stream, when the predicate returns true the folded value is yielded

Parameters

param Initial

Initial state

param Fold

Fold operation

param UntilValue

Predicate

returns

A pipe that folds

method Producer<S, M, Unit> FoldWhile <S, M, A> ( this Producer<S, M, A> ma, S Initial, Func<S, A, S> Fold, Func<S, bool> WhileState) Source #

where M : Monad<M>

Folds values coming down-stream, when the predicate returns true the folded value is yielded

Parameters

param Initial

Initial state

param Fold

Fold operation

param UntilValue

Predicate

returns

A pipe that folds

method Producer<OUT, M, Unit> merge_OLD <OUT, M> (Seq<Producer<OUT, M, Unit>> ms) Source #

where M : Monad<M>

Merge a sequence of producers into a single producer

The merged producer completes when all component producers have completed

Parameters

param ms

Sequence of producers to merge

returns

Merged producers

method Producer<OUT, M, Unit> merge <OUT, M> (Seq<Producer<OUT, M, Unit>> ms) Source #

where M : Monad<M>

method Producer<OUT, M, Unit> merge <OUT, M> (params Queue<OUT, M, Unit>[] ms) Source #

where M : Monad<M>

Merge an array of queues into a single producer

The merged producer completes when all component queues have completed

Parameters

param ms

Sequence of queues to merge

returns

Queues merged into a single producer

method Producer<OUT, M, Unit> merge <OUT, M> (params Producer<OUT, M, Unit>[] ms) Source #

where M : Monad<M>

Merge an array of producers into a single producer

The merged producer completes when all component producers have completed

Parameters

param ms

Sequence of producers to merge

returns

Merged producers

method Producer<OUT, M, Unit> merge <OUT, M> (params Proxy<Void, Unit, Unit, OUT, M, Unit>[] ms) Source #

where M : Monad<M>

Merge an array of producers into a single producer

The merged producer completes when all component producers have completed

Parameters

param ms

Sequence of producers to merge

returns

Merged producers

method Producer<OUT, M, Unit> merge <OUT, M> (Seq<Queue<OUT, M, Unit>> ms) Source #

where M : Monad<M>

Merge a sequence of queues into a single producer

The merged producer completes when all component queues have completed

Parameters

param ms

Sequence of queues to merge

returns

Queues merged into a single producer

method Producer<OUT, M, Unit> merge <OUT, M> (Seq<Proxy<Void, Unit, Unit, OUT, M, Unit>> ms) Source #

where M : Monad<M>

Merge a sequence of producers into a single producer

The merged producer completes when all component producers have completed

Parameters

param ms

Sequence of producers to merge

returns

Merged producers