LanguageExt.Core

LanguageExt.Core Monads State and Environment Monads State StateT

Contents

record StateT <S, M, A> (Func<S, K<M, (A Value, S State)>> runState) Source #

where M : Monad<M>, Choice<M>

StateT monad transformer, which adds a modifiable state to a given monad.

Parameters

type S

State type

type M

Given monad trait

type A

Bound value type

param runState

Transducer that represents the transformer operation

Properties

property StateT<S, M, S> Get Source #

Extracts the state value and returns it as the bound value

Parameters

returns

StateT

Methods

method StateT<S, M, A> Pure (A value) Source #

Lift a pure value into the monad-transformer

Parameters

param value

Value to lift

returns

StateT

method StateT<S, M, Unit> Modify (Func<S, S> f) Source #

Extracts the state value, maps it, and then puts it back into the monadic state.

Parameters

param f

State mapping function

returns

StateT

method StateT<S, M, Unit> ModifyM (Func<S, K<M, S>> f) Source #

Extracts the state value, maps it, and then puts it back into the monadic state.

Parameters

param f

State mapping function

returns

StateT

method StateT<S, M, Unit> Put (S value) Source #

Writes the value into the monadic state

Parameters

returns

StateT

method StateT<S, M, A> State (A value, S state) Source #

Writes a value and state into the monad

Parameters

returns

StateT

method StateT<S, M, A> State ((A value, S state) ma) Source #

Writes a value and state into the monad

Parameters

returns

StateT

method StateT<S, M, A> Gets (Func<S, A> f) Source #

Extracts the state value and maps it to the bound value

Parameters

param f

State mapping function

returns

StateT

method StateT<S, M, A> GetsM (Func<S, K<M, A>> f) Source #

Extracts the state value and maps it to the bound value

Parameters

param f

State mapping function

returns

StateT

method StateT<S, M, A> Lift (Pure<A> monad) Source #

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

StateT

method StateT<S, M, A> Lift (K<M, A> monad) Source #

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

StateT

method StateT<S, M, A> Lift (Func<A> f) Source #

Lifts a function into the transformer

Parameters

param f

Function to lift

returns

StateT

method StateT<S, M, A> LiftIO (IO<A> ma) Source #

Lifts an IO monad into the monad

NOTE: If the IO monad isn't the innermost monad of the transformer stack then this will throw an exception.

Parameters

param ma

IO monad to lift

returns

StateT

method StateT<S, M1, B> MapT <M1, B> (Func<K<M, (A Value, S State)>, K<M1, (B Value, S State)>> f) Source #

where M1 : Monad<M1>, Choice<M1>

Maps the given monad

Parameters

type M1

Trait of the monad to map to

param f

Mapping function

returns

StateT

method StateT<S, M, B> MapM <B> (Func<K<M, A>, K<M, B>> f) Source #

Maps the given monad

Parameters

param f

Mapping function

returns

StateT

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

Maps the bound value

Parameters

type B

Target bound value type

param f

Mapping function

returns

StateT

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

Maps the bound value

Parameters

type B

Target bound value type

param f

Mapping transducer

returns

StateT

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

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

StateT

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

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

StateT

method StateT<S, M, B> Bind <B> (Func<A, Gets<S, B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

StateT

method StateT<S, M, Unit> Bind (Func<A, Put<S>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

StateT

method StateT<S, M, Unit> Bind (Func<A, Modify<S>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

StateT

method StateT<S, M, B> Bind <B> (Func<A, IO<B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

StateT

method StateT<S, M, B> Bind <B> (Func<A, K<IO, B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

StateT

method StateT<S, M, C> SelectMany <B, C> (Func<A, K<StateT<S, M>, 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

StateT

method StateT<S, M, C> SelectMany <B, C> (Func<A, StateT<S, M, 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

StateT

method StateT<S, M, C> SelectMany <B, C> (Func<A, K<M, 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

StateT

method StateT<S, M, 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

StateT

method StateT<S, M, C> SelectMany <C> (Func<A, Put<S>> bind, Func<A, Unit, 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

StateT

method StateT<S, M, C> SelectMany <B, C> (Func<A, Gets<S, 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

StateT

method StateT<S, M, C> SelectMany <C> (Func<A, Modify<S>> bind, Func<A, Unit, 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

StateT

method StateT<S, M, C> SelectMany <B, C> (Func<A, IO<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

StateT

method StateT<S, M, C> SelectMany <B, C> (Func<A, K<IO, 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

StateT

method K<M, (A Value, S State)> Run (S state) Source #

Run the state monad

Parameters

param state

Initial state

returns

Bound monad

Operators

operator >> (StateT<S, M, A> lhs, StateT<S, M, 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 >> (StateT<S, M, A> lhs, K<StateT<S, M>, 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 >> (StateT<S, M, A> lhs, StateT<S, M, 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 >> (StateT<S, M, A> lhs, K<StateT<S, M>, 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 | (StateT<S, M, A> ma, K<StateT<S, M>, A> mb) Source #

Choice operator

operator | (K<StateT<S, M>, A> ma, StateT<S, M, A> mb) Source #

Choice operator

operator | (StateT<S, M, A> ma, Pure<A> mb) Source #

Choice operator

operator | (Pure<A> ma, StateT<S, M, A>mb) Source #

Choice operator

operator | (IO<A> ma, StateT<S, M, A> mb) Source #

Choice operator

operator | (StateT<S, M, A> ma, IO<A> mb) Source #

Choice operator

operator + (StateT<S, M, A> ma, K<StateT<S, M>, A> mb) Source #

Combine operator

operator + (K<StateT<S, M>, A> ma, StateT<S, M, A> mb) Source #

Combine operator

operator + (StateT<S, M, A> ma, Pure<A> mb) Source #

Combine operator

operator + (Pure<A> ma, StateT<S, M, A>mb) Source #

Combine operator

operator + (IO<A> ma, StateT<S, M, A> mb) Source #

Combine operator

operator + (StateT<S, M, A> ma, IO<A> mb) Source #

Combine operator

class StateTExtensions Source #

State monad extensions

Methods

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

where M : Monad<M>, Choice<M>

method K<M, (A Value, S State)> Run <S, M, A> (this K<StateT<S, M>, A> ma, S state) Source #

where M : Monad<M>, Choice<M>

Run the state monad

Parameters

param state

Initial state

returns

Bound monad

method StateT<S, M, A> Flatten <S, M, A> (this StateT<S, M, StateT<S, M, A>> mma) Source #

where M : Monad<M>, Choice<M>

Monadic join

method StateT<S, M, C> SelectMany <S, M, A, B, C> ( this K<M, A> ma, Func<A, K<StateT<S, M>, B>> bind, Func<A, B, C> project) Source #

where M : Monad<M>, Choice<M>

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

StateT

method StateT<S, M, C> SelectMany <S, M, A, B, C> ( this K<M, A> ma, Func<A, StateT<S, M, B>> bind, Func<A, B, C> project) Source #

where M : Monad<M>, Choice<M>

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

StateT

class StateTExtensions Source #

Methods

method StateT<S, M, B> Map <S, M, A, B> (this Func<A, B> f, K<StateT<S, M>, A> ma) Source #

where M : Monad<M>, Choice<M>

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 StateT<S, M, B> Map <S, M, A, B> (this Func<A, B> f, StateT<S, M, A> ma) Source #

where M : Monad<M>, Choice<M>

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 StateT<S, M, B> Action <S, M, A, B> (this StateT<S, M, A> ma, K<StateT<S, M>, B> mb) Source #

where M : Monad<M>, Choice<M>

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

method StateT<S, M, B> Action <S, M, A, B> (this K<StateT<S, M>, A> ma, K<StateT<S, M>, B> mb) Source #

where M : Monad<M>, Choice<M>

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

method StateT<S, M, B> Apply <S, M, A, B> (this StateT<S, M, Func<A, B>> mf, K<StateT<S, M>, A> ma) Source #

where M : Monad<M>, Choice<M>

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 StateT<S, M, B> Apply <S, M, A, B> (this K<StateT<S, M>, Func<A, B>> mf, K<StateT<S, M>, A> ma) Source #

where M : Monad<M>, Choice<M>

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 StateT <S> Source #

Methods

method StateT<S, M, A> lift <M, A> (K<M, A> ma) Source #

where M : Monad<M>, Choice<M>

class StateT <S, M> Source #

Methods

method StateT<S, M, A> pure <A> (A value) Source #

method StateT<S, M, A> liftIO <A> (IO<A> effect) Source #

Lifts a given monad into the transformer

Parameters

param effect

Monad to lift

returns

StateT

class StateT Source #

Methods

method StateT<S, M, A> pure <S, M, A> (A value) Source #

where M : Monad<M>, Choice<M>

method StateT<S, M, A> lift <S, M, A> (K<M, A> ma) Source #

where M : Monad<M>, Choice<M>

method StateT<S, M, A> liftIO <S, M, A> (IO<A> effect) Source #

where M : Monad<M>, Choice<M>

Lifts a given monad into the transformer

Parameters

param effect

Monad to lift

returns

StateT

method StateT<S, M, S> get <M, S> () Source #

where M : Monad<M>, Choice<M>

method StateT<S, M, A> gets <M, S, A> (Func<S, A> f) Source #

where M : Monad<M>, Choice<M>

method StateT<S, M, A> getsM <M, S, A> (Func<S, K<M, A>> f) Source #

where M : Monad<M>, Choice<M>

method StateT<S, M, Unit> put <M, S> (S state) Source #

where M : Monad<M>, Choice<M>

method StateT<S, M, Unit> modify <M, S> (Func<S, S> f) Source #

where M : Monad<M>, Choice<M>

method StateT<S, M, Unit> modifyM <M, S> (Func<S, K<M, S>> f) Source #

where M : Monad<M>, Choice<M>

class StateT <S, M> Source #

where M : Monad<M>, Choice<M>

MonadStateT trait implementation for StateT

Parameters

type S

State environment type

type M

Given monad trait

class Prelude Source #

Methods

method StateT<S, M, B> map <S, M, A, B> (Func<A, B> f, K<StateT<S, M>, A> ma) Source #

where M : Monad<M>, Choice<M>

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 StateT<S, M, B> action <S, M, A, B> (K<StateT<S, M>, A> ma, K<StateT<S, M>, B> mb) Source #

where M : Monad<M>, Choice<M>

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

method StateT<S, M, B> apply <S, M, A, B> (K<StateT<S, M>, Func<A, B>> mf, K<StateT<S, M>, A> ma) Source #

where M : Monad<M>, Choice<M>

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