LanguageExt.Core

LanguageExt.Core Monads State and Environment Monads Reader Reader

Contents

record Reader <Env, A> (Func<Env, A> runReader) Source #

Reader monad transformer, which adds a static environment to a given monad.

Parameters

type Env

Reader environment type

type M

Given monad trait

type A

Bound value type

Methods

method Reader<Env, A> Pure (A value) Source #

Lift a pure value into the monad-transformer

Parameters

param value

Value to lift

returns

Reader

method Reader<Env, A> Asks (Func<Env, A> f) Source #

Extracts the environment value and maps it to the bound value

Parameters

param f

Environment mapping function

returns

Reader

method Reader<Env, A> AsksM (Func<Env, Reader<Env, A>> f) Source #

Extracts the environment value and maps it to the bound value

Parameters

param f

Environment mapping function

returns

Reader

method Reader<Env, A> Lift (Pure<A> monad) Source #

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

Reader

method Reader<Env, A> Lift (Func<A> f) Source #

Lifts a unit function into the transformer

Parameters

param f

Function to lift

returns

Reader

method Reader<Env1, A> With <Env1> (Func<Env1, Env> f) Source #

Maps the Reader's environment value

Parameters

param f

Mapping function

returns

Reader

method Reader<Env, A> Local (Func<Env, Env> f) Source #

Maps the Reader's environment value

Parameters

param f

Mapping function

returns

Reader

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

Maps the bound value

Parameters

type B

Target bound value type

param f

Mapping function

returns

Reader

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

Maps the bound value

Parameters

type B

Target bound value type

param f

Mapping transducer

returns

Reader

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

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

Reader

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

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

Reader

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

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

Reader

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

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

Reader

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

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

Reader

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

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

Reader

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

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

Reader

method A Run (Env env) Source #

Run the reader monad

Parameters

param env

Input environment

returns

Computed value

Operators

operator >> (Reader<Env, A> lhs, Reader<Env, 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 >> (Reader<Env, A> lhs, K<Reader<Env>, 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 >> (Reader<Env, A> lhs, Reader<Env, 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 >> (Reader<Env, A> lhs, K<Reader<Env>, 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 ReaderExtensions Source #

Reader monad extensions

Methods

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

method A Run <Env, A> (this K<Reader<Env>, A> ma, Env env) Source #

Run the reader monad

Parameters

param env

Input environment

method Reader<Env, A> Flatten <Env, A> (this Reader<Env, Reader<Env, A>> mma) Source #

Monadic join

class ReaderExtensions Source #

Methods

method Reader<Env, B> Map <Env, A, B> (this Func<A, B> f, K<Reader<Env>, A> ma) Source #

Functor map operation

Unwraps the value within the functor, passes it to the map function f provided, and then takes the mapped value and wraps it back up into a new functor.

Parameters

param ma

Functor to map

param f

Mapping function

returns

Mapped functor

method Reader<Env, B> Map <Env, A, B> (this Func<A, B> f, Reader<Env, A> ma) Source #

Functor map operation

Unwraps the value within the functor, passes it to the map function f provided, and then takes the mapped value and wraps it back up into a new functor.

Parameters

param ma

Functor to map

param f

Mapping function

returns

Mapped functor

method Reader<Env, B> Action <Env, A, B> (this Reader<Env, A> ma, K<Reader<Env>, B> mb) Source #

Applicative action: runs the first applicative, ignores the result, and returns the second applicative

method Reader<Env, B> Action <Env, A, B> (this K<Reader<Env>, A> ma, K<Reader<Env>, B> mb) Source #

Applicative action: runs the first applicative, ignores the result, and returns the second applicative

method Reader<Env, B> Apply <Env, A, B> (this Reader<Env, Func<A, B>> mf, K<Reader<Env>, A> ma) Source #

Applicative functor apply operation

Unwraps the value within the ma applicative-functor, passes it to the unwrapped function(s) within mf, and then takes the resulting value and wraps it back up into a new applicative-functor.

Parameters

param ma

Value(s) applicative functor

param mf

Mapping function(s)

returns

Mapped applicative functor

method Reader<Env, B> Apply <Env, A, B> (this K<Reader<Env>, Func<A, B>> mf, K<Reader<Env>, A> ma) Source #

Applicative functor apply operation

Unwraps the value within the ma applicative-functor, passes it to the unwrapped function(s) within mf, and then takes the resulting value and wraps it back up into a new applicative-functor.

Parameters

param ma

Value(s) applicative functor

param mf

Mapping function(s)

returns

Mapped applicative functor

class Reader Source #

Methods

method Reader<Env, A> pure <Env, A> (A value) Source #

method Reader<Env, Env> ask <Env> () Source #

method Reader<Env, A> asks <Env, A> (Func<Env, A> f) Source #

method Reader<Env, A> asksM <Env, A> (Func<Env, Reader<Env, A>> f) Source #

method Reader<Env, A> local <Env, A> (Func<Env, Env> f, Reader<Env, A> ma) Source #

class Reader <Env> Source #

Trait implementation for Reader

Parameters

type Env

Reader environment type

class Prelude Source #

Methods

method Reader<Env, B> map <Env, A, B> (Func<A, B> f, K<Reader<Env>, A> ma) Source #

Functor map operation

Unwraps the value within the functor, passes it to the map function f provided, and then takes the mapped value and wraps it back up into a new functor.

Parameters

param ma

Functor to map

param f

Mapping function

returns

Mapped functor

method Reader<Env, B> action <Env, A, B> (K<Reader<Env>, A> ma, K<Reader<Env>, B> mb) Source #

Applicative action: runs the first applicative, ignores the result, and returns the second applicative

method Reader<Env, B> apply <Env, A, B> (K<Reader<Env>, Func<A, B>> mf, K<Reader<Env>, A> ma) Source #

Applicative functor apply operation

Unwraps the value within the ma applicative-functor, passes it to the unwrapped function(s) within mf, and then takes the resulting value and wraps it back up into a new applicative-functor.

Parameters

param ma

Value(s) applicative functor

param mf

Mapping function(s)

returns

Mapped applicative functor