LanguageExt.Core

LanguageExt.Core Monads State and Environment Monads State

Contents

delegate State <S, A> Source #

class StateExtensions Source #

Extension methods for State

Methods

method State<Env, A> Flatten <Env, A> (this State<Env, State<Env, A>> ma) Source #

Monadic join

method (TryOption<A> Value, S State) Run <S, A> (this State<S, A> self, S state) Source #

Runs the State monad and memoizes the result in a TryOption monad. Use Match, IfSucc, IfNone, etc to extract.

method State<S, int> Sum <S> (this State<S, int> self) Source #

method State<S, Seq<A>> ToSeq <S, A> (this State<S, A> self) Source #

method Seq<A> ToSeq <S, A> (this State<S, A> self, S state) Source #

method State<S, Seq<A>> AsEnumerable <S, A> (this State<S, A> self) Source #

method Seq<A> AsEnumerable <S, A> (this State<S, A> self, S state) Source #

method State<S, int> Count <S> (this State<S, int> self) Source #

method State<S, bool> ForAll <S, A> (this State<S, A> self, Func<A, bool> pred) Source #

method State<S, bool> Exists <S, A> (this State<S, A> self, Func<A, bool> pred) Source #

method State<S, FState> Fold <FState, S, A> (this State<S, A> self, FState initialState, Func<FState, A, FState> f) Source #

method State<S, S> Fold <S, A> (this State<S, A> self, Func<S, A, S> f) Source #

method State<S, A> Strict <S, A> (this State<S, A> ma) Source #

Force evaluation of the monad (once only)

method State<S, A> Do <S, A> (this State<S, A> ma, Action<A> f) Source #

Impure iteration of the bound value in the structure

Parameters

returns

Returns the original unmodified structure

method State<S, B> Map <S, A, B> (this State<S, A> self, Func<A, B> f) Source #

method State<S, Unit> Modify <S, A> (this State<S, A> self, Func<S, S> f) Source #

Monadic state transformer. Maps an old state to a new state inside a state monad. The old state is thrown away.

method State<S, B> Bind <S, A, B> (this State<S, A> self, Func<A, State<S, B>> f) Source #

method State<S, B> Select <S, A, B> (this State<S, A> self, Func<A, B> f) Source #

method State<S, C> SelectMany <S, A, B, C> ( this State<S, A> self, Func<A, State<S, B>> bind, Func<A, B, C> project) Source #

method State<S, A> Filter <S, A> (this State<S, A> self, Func<A, bool> pred) Source #

method State<S, A> Where <S, A> (this State<S, A> self, Func<A, bool> pred) Source #

method State<S, Unit> Iter <S, A> (this State<S, A> self, Action<A> action) Source #

class Prelude Source #

Methods

method State<Env, A> flatten <Env, A> (State<Env, State<Env, A>> ma) Source #

Monadic join

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

State monad constructor

Parameters

type S

State type

type A

Bound value type

param value

Value

returns

State monad

method State<S, A> State <S, A> (Func<S, (A, S)> f) Source #

State monad constructor

Parameters

type S

State type

type A

Bound value type

param value

Value

returns

State monad

method State<S, S> get <S> () Source #

Get the state from monad into its wrapped value

Parameters

type S

State type

returns

State monad with state in the value

method State<A, B> get <A, B> (Lens<A, B> la) Source #

Applies a lens in the 'get' direction within a state monad

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

Set the state

Parameters

type S

State type

returns

State monad with state set and with a Unit value

method State<A, Unit> put <A, B> (Lens<A, B> la, B value) Source #

Applies a lens in the 'set' direction within a state monad

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

modify::MonadState s m => (s -> s) -> m()

Monadic state transformer.

Maps an old state to a new state inside a state monad.The old state is thrown away.

method State<A, Unit> modify <A, B> (Lens<A, B> la, Func<B, B> f) Source #

Update through a lens within a state monad

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

gets :: MonadState s m => (s -> a) -> m a

Gets specific component of the state, using a projection function supplied.

method State<S, Option<A>> choose <S, A> (params State<S, Option<A>>[] monads) Source #

Chooses the first monad result that has a Some(x) for the value

method State<S, A> trystate <S, A> (State<S, A> value) Source #

method Try<State<S, A>> tryfun <S, A> (State<S, A> ma) Source #

class StateResult Source #

Convenience methods for returning from a State<S,A> computation

Methods

method (A Value, S State, bool IsBottom) ToState <S, A> (this (A, S) self) Source #

method (A Value, S State, bool IsBottom) Return <S, A> (A value, S state) Source #

method (Unit Value, S State, bool IsBottom) Return <S> (S state) Source #

method (A Value, S State, bool IsBottom) Fail <S, A> () Source #

method (Unit Value, S State, bool IsBottom) Fail <S> () Source #