LanguageExt.Pipes

LanguageExt.Pipes Pipe

Contents

record Pipe <IN, OUT, M, A> Source #

where M : Monad<M>

Pipes both can both be await and can yield

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

Fields

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

Constructors

constructor Pipe (Proxy<Unit, IN, Unit, OUT, M, A> value) Source #

Constructor

Parameters

param value

Correctly shaped Proxy that represents a Pipe

Methods

method Proxy<Unit, IN, 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<Unit, IN, Unit, OUT, M, S> Bind <S> ( Func<A, Proxy<Unit, IN, 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 Pipe<IN, 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 Pipe<IN, 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<Unit, IN, 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<Unit, IN, 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 Proxy<Unit, IN, Unit, OUT, M, IO<A>> ToIO () Source #

Extract the lifted IO monad (if there is one)

Parameters

param f

The map function

returns

A new Proxy that represents the innermost IO monad, if it exists.

method Pipe<IN, OUT, M, B> Bind <B> (Func<A, Pipe<IN, 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 Pipe<IN, 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<Unit, IN, C1, C, M, A> For <C1, C> ( Func<OUT, Proxy<Unit, IN, 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<Unit, IN, Unit, OUT, M, S> Action <S> (Proxy<Unit, IN, Unit, OUT, M, S> 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<Unit, Proxy<UOutA, AUInA, Unit, IN, 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<Unit, Proxy<UOutA, AUInA, Unit, OUT, M, IN>> 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<Unit, IN, 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<Unit, IN, DInC, DOutC, M, A> ReplaceRespond <DInC, DOutC> ( Func<OUT, Proxy<Unit, IN, 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, IN, Unit, M, A> Reflect () Source #

Reverse the arrows of the Proxy to find its dual.

Parameters

returns

The dual of this

method Proxy<Unit, IN, 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<Unit, IN, Unit, OUT, M, A> value) Source #

method Pipe<IN, C, M, A> Then <C> (Pipe<OUT, C, M, A> pipe) Source #

Composition chaining of two pipes.

We can't provide the operator overloading to chain two pipes together, because operators don't have generics of their own. And so we can use this method to chain to pipes together.

Parameters

type C

Type of value that the right hand side pipe yields

param pipe

Right hand side Pipe

returns

A composition of this pipe and the Pipe provided

method Pipe<IN, OUT, M, B> SelectMany <B> (Func<A, Pipe<IN, 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 Pipe<IN, OUT, M, C> SelectMany <B, C> (Func<A, Pipe<IN, 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 Pipe<IN, OUT, M, B> SelectMany <B> (Func<A, Pipe<IN, 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 Pipe<IN, OUT, M, C> SelectMany <B, C> (Func<A, Pipe<IN, 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 Pipe<IN, 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 Pipe<IN, OUT, M, C> SelectMany <B, C> (Func<A, IO<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<IN, M, A> p1, Pipe<IN, OUT, M, A> p2) Source #

Compose a Producer and a Pipe together into a Producer.

Parameters

param p1

Producer

param p2

Pipe

returns

Producer

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

Compose a Producer and a Pipe together into a Producer.

Parameters

param p1

Producer

param p2

Pipe

returns

Producer

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

Compose a Producer and a Pipe together into a Producer.

Parameters

param p1

Producer

param p2

Pipe

returns

Producer

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

Compose a Pipe and a Consumer together into a Consumer.

Parameters

param p1

Pipe

param p2

Consumer

returns

Consumer

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

Compose a Pipe and a Consumer together into a Consumer.

Parameters

param p1

Pipe

param p2

Consumer

returns

Consumer

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

Chain one pipe's set of awaits and yields after another

class Pipe Source #

Pipes both can both be await and can yield

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

Methods

method Pipe<A, B, M, R> Pure <A, B, M, R> (R value) Source #

where M : Monad<M>

Monad return / pure

method Pipe<A, Y, M, A> awaiting <M, A, Y> () Source #

where M : Monad<M>

Wait for a value from upstream (whilst in a pipe)

This is the version of await that works for pipes. In consumers, use Consumer.await

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

where M : Monad<M>

Send a value downstream (whilst in a pipe)

This is the version of yield that works for pipes. In producers, use Producer.yield

method Pipe<A, A, M, Unit> filter <M, A> (Func<A, bool> f) Source #

where M : Monad<M>

Only forwards values that satisfy the predicate.

method Pipe<A, B, M, R> map <A, B, M, R> (Func<A, B> f) Source #

where M : Monad<M>

Map the output of the pipe (not the bound value as is usual with Map)

method Pipe<A, B, M, Unit> map <A, M, B> (Func<A, B> f) Source #

where M : Monad<M>

Map the output of the pipe (not the bound value as is usual with Map)

method Pipe<A, B, Unit> map <A, B> (Func<A, B> f) Source #

Map the output of the pipe (not the bound value as is usual with Map)

method Pipe<A, B, M, R> mapM <A, B, M, R> (Func<A, K<M, B>> f) Source #

where M : Monad<M>

Apply a monadic function to all values flowing downstream (not the bound value as is usual with Map)

method Pipe<A, B, M, R> lift <A, B, M, R> (K<M, R> ma) Source #

where M : Monad<M>

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

method Pipe<A, B, M, R> liftIO <A, B, M, R> (IO<R> ma) Source #

where M : Monad<M>

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

method Pipe<IN, OUT, M, Unit> foldWhile <IN, OUT, M> ( OUT Initial, Func<OUT, IN, OUT> Fold, Func<OUT, bool> WhileState) Source #

where M : Monad<M>

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

Parameters

param Initial

Initial state

param Fold

Fold operation

param WhileState

Predicate

returns

A pipe that folds

method Pipe<IN, OUT, M, Unit> foldUntil <IN, OUT, M> ( OUT Initial, Func<OUT, IN, OUT> Fold, Func<OUT, 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 UntilState

Predicate

returns

A pipe that folds

method Pipe<IN, OUT, M, Unit> foldWhile <IN, OUT, M> ( OUT Initial , Func<OUT, IN, OUT> Fold, Func<IN, bool> WhileValue) Source #

where M : Monad<M>

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

Parameters

param Initial

Initial state

param Fold

Fold operation

param WhileValue

Predicate

returns

A pipe that folds

method Pipe<IN, OUT, M, Unit> foldUntil <IN, OUT, M> ( OUT Initial, Func<OUT, IN, OUT> Fold, Func<IN, 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 Pipe<IN, OUT, M, Unit> scan <IN, OUT, M, S> (Func<S, IN, S> Step, S Begin, Func<S, OUT> Done) Source #

where M : Monad<M>

Strict left scan