LanguageExt.Core

LanguageExt.Core Monads State and Environment Monads RWS

Contents

delegate RWS <MonoidW, R, W, S, A> Source #

where MonoidW : struct, Monoid<W>

struct RWSState <W, S> Source #

Fields

field RWSState<W, S> Bottom = new RWSState<W, S>() Source #

field W Output Source #

field S State Source #

Properties

property bool IsFaulted Source #

struct RWSResult <MonoidW, R, W, S, A> Source #

where MonoidW : struct, Monoid<W>

Fields

field RWSResult<MonoidW, R, W, S, A> Bottom = new RWSResult<MonoidW, R, W, S, A>() Source #

field W Output Source #

field S State Source #

Properties

property bool IsFaulted Source #

Methods

method RWSResult<MonoidW, R, W, S, A> New (S state, A value) Source #

method RWSResult<MonoidW, R, W, S, A> New (W output, S state, A value) Source #

method RWSResult<MonoidW, R, W, S, A> New (S state, Error error) Source #

method RWSResult<MonoidW, R, W, S, A> New (W output, S state, Error error) Source #

method B Match <B> (Func<A, B> Succ, Func<Error, B> Fail) Source #

method Unit Match (Action<A> Succ, Action<Error> Fail) Source #

method A IfFail (A value) Source #

method A IfFailThrow () Source #

method Option<A> ToOption () Source #

method OptionUnsafe<A> ToOptionUnsafe () Source #

method OptionAsync<A> ToOptionAsync () Source #

method Seq<A> ToSeq () Source #

method Lst<A> ToList () Source #

method Either<Error, A> ToEither () Source #

method Either<L, A> ToEither <L> (Func<Error, L> Left) Source #

method EitherUnsafe<Error, A> ToEitherUnsafe () Source #

method EitherUnsafe<L, A> ToEitherUnsafe <L> (Func<Error, L> Left) Source #

method EitherAsync<Error, A> ToEitherAsync () Source #

method EitherAsync<L, A> ToEitherAsync <L> (Func<Error, L> Left) Source #

method Try<A> ToTry () Source #

method TryAsync<A> ToTryAsync () Source #

method Reader<R, A> ToReader () Source #

method Writer<MonoidW, W, A> ToWriter () Source #

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

method bool Equals (object obj) Source #

method int GetHashCode () Source #

method bool Equals (RWSResult<MonoidW, R, W, S, A> right) Source #

method bool Equals (A right) Source #

method void Deconstruct (out A Value, out W Output, out S State, out Option<Error> Error) Source #

Operators

operator == (RWSResult<MonoidW, R, W, S, A> left, A right) Source #

operator != (RWSResult<MonoidW, R, W, S, A> left, A right) Source #

operator == (RWSResult<MonoidW, R, W, S, A> left, RWSResult<MonoidW, R, W, S, A> right) Source #

operator != (RWSResult<MonoidW, R, W, S, A> left, RWSResult<MonoidW, R, W, S, A> right) Source #

class RWSExtensions Source #

Extension methods for RWS

Methods

method RWS<MonoidW, R, W, S, A> Flatten <MonoidW, R, W, S, A> (this RWS<MonoidW, R, W, S, RWS<MonoidW, R, W, S, A>> ma) Source #

where MonoidW : struct, Monoid<W>

Monadic join

method RWSResult<MonoidW, R, W, S, A> Run <MonoidW, R, W, S, A> (this RWS<MonoidW, R, W, S, A> self, R env, S state) Source #

where MonoidW : struct, Monoid<W>

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

method RWS<MonoidW, R, W, S, int> Sum <MonoidW, R, W, S> (this RWS<MonoidW, R, W, S, int> self) Source #

where MonoidW : struct, Monoid<W>

method RWS<MonoidW, R, W, S, Seq<A>> ToSeq <MonoidW, R, W, S, A> (this RWS<MonoidW, R, W, S, A> self) Source #

where MonoidW : struct, Monoid<W>

method RWS<MonoidW, R, W, S, Seq<A>> AsEnumerable <MonoidW, R, W, S, A> (this RWS<MonoidW, R, W, S, A> self) Source #

where MonoidW : struct, Monoid<W>

method Seq<A> ToSeq <MonoidW, R, W, S, A> (this RWS<MonoidW, R, W, S, A> self, R env, S state) Source #

where MonoidW : struct, Monoid<W>

method Seq<A> AsEnumerable <MonoidW, R, W, S, A> (this RWS<MonoidW, R, W, S, A> self, R env, S state) Source #

where MonoidW : struct, Monoid<W>

method RWS<MonoidW, R, W, S, int> Count <MonoidW, R, W, S, A> (this RWS<MonoidW, R, W, S, A> self) Source #

where MonoidW : struct, Monoid<W>

method RWS<MonoidW, R, W, S, bool> Exists <MonoidW, R, W, S, A> (this RWS<MonoidW, R, W, S, A> self, Func<A, bool> pred) Source #

where MonoidW : struct, Monoid<W>

method RWS<MonoidW, R, W, S, bool> ForAll <MonoidW, R, W, S, A> (this RWS<MonoidW, R, W, S, A> self, Func<A, bool> pred) Source #

where MonoidW : struct, Monoid<W>

method RWS<MonoidW, R, W, S, B> Fold <MonoidW, R, W, S, A, B> (this RWS<MonoidW, R, W, S, A> self, B initialValue, Func<B, A, B> f) Source #

where MonoidW : struct, Monoid<W>

method RWS<MonoidW, R, W, S, R> Fold <MonoidW, R, W, S, A> (this RWS<MonoidW, R, W, S, A> self, Func<R, A, R> f) Source #

where MonoidW : struct, Monoid<W>

method RWS<MonoidW, R, W, S, A> Strict <MonoidW, R, W, S, A> (this RWS<MonoidW, R, W, S, A> ma) Source #

where MonoidW : struct, Monoid<W>

Force evaluation of the monad (once only)

method RWS<MonoidW, R, W, S, A> Do <MonoidW, R, W, S, A> (this RWS<MonoidW, R, W, S, A> ma, Action<A> f) Source #

where MonoidW : struct, Monoid<W>

Impure iteration of the bound value in the structure

Parameters

returns

Returns the original unmodified structure

method RWS<MonoidW, R, W, S, Unit> Modify <MonoidW, R, W, S, A> (RWS<MonoidW, R, W, S, A> self, Func<S, S> f) Source #

where MonoidW : struct, Monoid<W>

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

method RWS<MonoidW, R, W, S, B> Map <MonoidW, R, W, S, A, B> (this RWS<MonoidW, R, W, S, A> self, Func<A, B> project) Source #

where MonoidW: struct, Monoid<W>

method RWS<MonoidW, R, W, S, A> Pass <MonoidW, R, W, S, A> (this RWS<MonoidW, R, W, S, (A, Func<W, W>)> self) Source #

where MonoidW : struct, Monoid<W>

Pass is an action that executes the monad, which returns a value and a function, and returns the value, applying the function to the output.

method RWS<MonoidW, R, W, S, (A, B)> Listen <MonoidW, R, W, S, A, B> (this RWS<MonoidW, R, W, S, A> ma, Func<W, B> f) Source #

where MonoidW : struct, Monoid<W>

Listen is an action that executes the monad and adds its output to the value of the computation.

method RWS<MonoidW, R, W, S, A> Censor <MonoidW, R, W, S, A> (this RWS<MonoidW, R, W, S, A> ma, Func<W, W> f) Source #

where MonoidW : struct, Monoid<W>

Censor is an action that executes the monad and applies the function f to its output, leaving the return value unchanged.

method RWS<MonoidW, R, W, S, B> Bind <MonoidW, R, W, S, A, B> (this RWS<MonoidW, R, W, S, A> ma, Func<A, RWS<MonoidW, R, W, S, B>> f) Source #

where MonoidW : struct, Monoid<W>

method RWS<MonoidW, R, W, S, B> Select <MonoidW, R, W, S, A, B> (this RWS<MonoidW, R, W, S, A> ma, Func<A, B> f) Source #

where MonoidW : struct, Monoid<W>

method RWS<MonoidW, R, W, S, C> SelectMany <MonoidW, R, W, S, A, B, C> ( this RWS<MonoidW, R, W, S, A> ma, Func<A, RWS<MonoidW, R, W, S, B>> bind, Func<A, B, C> project) Source #

where MonoidW : struct, Monoid<W>

method RWS<MonoidW, R, W, S, A> Filter <MonoidW, R, W, S, A> (this RWS<MonoidW, R, W, S, A> self, Func<A, bool> pred) Source #

where MonoidW : struct, Monoid<W>

method RWS<MonoidW, R, W, S, A> Where <MonoidW, R, W, S, A> (this RWS<MonoidW, R, W, S, A> self, Func<A, bool> pred) Source #

where MonoidW : struct, Monoid<W>

method RWS<MonoidW, R, W, S, Unit> Iter <MonoidW, R, W, S, A> (this RWS<MonoidW, R, W, S, A> self, Action<A> action) Source #

where MonoidW : struct, Monoid<W>

class Prelude Source #

Methods

method RWS<MonoidW, R, W, S, A> flatten <MonoidW, R, W, S, A> (RWS<MonoidW, R, W, S, RWS<MonoidW, R, W, S, A>> ma) Source #

where MonoidW : struct, Monoid<W>

Monadic join

method RWS<MonoidW, R, W, S, A> RWS <MonoidW, R, W, S, A> (A value) Source #

where MonoidW : struct, Monoid<W>

RWS monad constructor

Parameters

type R

Environment type

type W

Writer type

type S

State type

type A

Bound value type

param value

Value

returns

RWS monad

method RWS<MonoidW, R, W, S, A> RWS <MonoidW, R, W, S, A> (S state, A value) Source #

where MonoidW : struct, Monoid<W>

RWS monad constructor

Parameters

type R

Environment type

type W

Writer type

type S

State type

type A

Bound value type

param value

Value

returns

RWS monad

method RWS<MonoidW, R, W, S, A> RWS <MonoidW, R, W, S, A> (W output, S state, A value) Source #

where MonoidW : struct, Monoid<W>

RWS monad constructor

Parameters

type R

Environment type

type W

Writer type

type S

State type

type A

Bound value type

param value

Value

returns

RWS monad

method RWS<MonoidW, R, W, S, A> RWS <MonoidW, R, W, S, A> (W output, A value) Source #

where MonoidW : struct, Monoid<W>

RWS monad constructor

Parameters

type R

Environment type

type W

Writer type

type S

State type

type A

Bound value type

param value

Value

returns

RWS monad

method RWS<MonoidW, R, W, S, A> RWS <MonoidW, R, W, S, A> (Func<R, S, (A, W, S)> f) Source #

where MonoidW : struct, Monoid<W>

RWS monad constructor

Parameters

type R

Environment type

type W

Writer type

type S

State type

type A

Bound value type

param value

Value

returns

RWS monad

method RWS<MonoidW, R, W, S, A> RWSFail <MonoidW, R, W, S, A> (Error error) Source #

where MonoidW : struct, Monoid<W>

RWS failure constructor

Parameters

type R

Environment type

type W

Writer type

type S

State type

type A

Bound value type

param value

Value

returns

RWS monad

method RWS<MonoidW, R, W, S, A> RWSFail <MonoidW, R, W, S, A> (Exception exception) Source #

where MonoidW : struct, Monoid<W>

RWS failure constructor

Parameters

type R

Environment type

type W

Writer type

type S

State type

type A

Bound value type

param value

Value

returns

RWS monad

method RWS<MonoidW, R, W, S, A> RWSFail <MonoidW, R, W, S, A> (string message, Exception exception) Source #

where MonoidW : struct, Monoid<W>

RWS failure constructor

Parameters

type R

Environment type

type W

Writer type

type S

State type

type A

Bound value type

param value

Value

returns

RWS monad

method RWS<MonoidW, R, W, S, A> RWSFail <MonoidW, R, W, S, A> (string message) Source #

where MonoidW : struct, Monoid<W>

RWS failure constructor

Parameters

type R

Environment type

type W

Writer type

type S

State type

type A

Bound value type

param value

Value

returns

RWS monad

method RWS<MonoidW, R, W, S, S> get <MonoidW, R, W, S, A> () Source #

where MonoidW : struct, Monoid<W>

Get the state from monad into its wrapped value

Parameters

type R

Environment type

type W

Writer type

type S

State type

type A

Bound value type

returns

RWS monad with state in the value

method RWS<MonoidW, R, W, S, Unit> put <MonoidW, R, W, S, A> (S state) Source #

where MonoidW : struct, Monoid<W>

Set the state from monad into its wrapped value

Parameters

type R

Environment type

type W

Writer type

type S

State type

type A

Bound value type

returns

RWS monad with state set and with Unit value

method RWS<MonoidW, R, W, S, Unit> modify <MonoidW, R, W, S, A> (Func<S, S> f) Source #

where MonoidW : struct, Monoid<W>

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

Parameters

type R

Environment type

type W

Writer type

type S

State type

type A

Bound value type

returns

RWS monad with state set and with Unit value

method RWS<MonoidW, R, W, S, A> gets <MonoidW, R, W, S, A> (Func<S, A> f) Source #

where MonoidW : struct, Monoid<W>

Gets a projection of the state

Parameters

type R

Environment type

type W

Writer type

type S

State type

type A

Bound value type

returns

RWS monad with projected value

method RWS<MonoidW, R, W, S, R> ask <MonoidW, R, W, S> () Source #

where MonoidW : struct, Monoid<W>

Retrieves the reader monad environment.

Parameters

type R

Environment type

type W

Writer type

type S

State type

type A

Bound value type

returns

RWS monad with the environment in as the bound value

method RWS<MonoidW, R, W, S, A> asks <MonoidW, R, W, S, A> (Func<R, A> f) Source #

where MonoidW : struct, Monoid<W>

Retrieves a function of the current environment.

Parameters

type R

Environment type

type W

Writer type

type S

State type

type A

Bound value type

returns

RWS monad with the mapped environment in as the bound value

method RWS<MonoidW, R, W, S, A> local <MonoidW, R, W, S, A> (RWS<MonoidW, R, W, S, A> ma, Func<R, R> f) Source #

where MonoidW : struct, Monoid<W>

Executes a computation in a modified environment

Parameters

type R

Environment type

type W

Writer type

type S

State type

type A

Bound value type

returns

RWS monad with the mapped environment in as the bound value

method RWS<MonoidW, R, W, S, Option<A>> choose <MonoidW, R, W, S, A> (params RWS<MonoidW, R, W, S, Option<A>>[] monads) Source #

where MonoidW : struct, Monoid<W>

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

Parameters

type R

Environment type

type W

Writer type

type S

State type

type A

Bound value type

returns

RWS monad with the mapped environment in as the bound value

method RWS<MonoidW, R, W, S, A> tryrws <MonoidW, R, W, S, A> (RWS<MonoidW, R, W, S, A> m) Source #

where MonoidW : struct, Monoid<W>

Run the RWS and catch exceptions

Parameters

type R

Environment type

type W

Writer type

type S

State type

type A

Bound value type

returns

RWS monad with the mapped environment in as the bound value

method Try<RWS<MonoidW, R, W, S, A>> tryfun <MonoidW, R, W, S, A> (RWS<MonoidW, R, W, S, A> ma) Source #

where MonoidW : struct, Monoid<W>

Run the RWS and catch exceptions

Parameters

type R

Environment type

type W

Writer type

type S

State type

type A

Bound value type

returns

RWS monad with the mapped environment in as the bound value

method RWS<MonoidW, R, W, S, int> sum <MonoidW, R, W, S, A> (RWS<MonoidW, R, W, S, int> self) Source #

where MonoidW : struct, Monoid<W>

method RWS<MonoidW, R, W, S, int> count <MonoidW, R, W, S, A> (RWS<MonoidW, R, W, S, A> self) Source #

where MonoidW : struct, Monoid<W>

method RWS<MonoidW, R, W, S, bool> forall <MonoidW, R, W, S, A> (RWS<MonoidW, R, W, S, A> self, Func<A, bool> pred) Source #

where MonoidW : struct, Monoid<W>

method RWS<MonoidW, R, W, S, bool> exists <MonoidW, R, W, S, A> (RWS<MonoidW, R, W, S, A> self, Func<A, bool> pred) Source #

where MonoidW : struct, Monoid<W>

method RWS<MonoidW, R, W, S, FState> fold <MonoidW, R, W, S, A, FState> (RWS<MonoidW, R, W, S, A> self, FState initial, Func<FState, A, FState> f) Source #

where MonoidW : struct, Monoid<W>

method RWS<MonoidW, R, W, S, R> fold <MonoidW, R, W, S, A, FState> (RWS<MonoidW, R, W, S, A> self, Func<R, A, R> f) Source #

where MonoidW : struct, Monoid<W>

method RWS<MonoidW, R, W, S, A> pass <MonoidW, R, W, S, A> (RWS<MonoidW, R, W, S, (A, Func<W, W>)> self) Source #

where MonoidW : struct, Monoid<W>

Pass is an action that executes the monad, which returns a value and a function, and returns the value, applying the function to the output.

Parameters

type R

Environment type

type W

Writer type

type S

State type

type A

Bound value type

method RWS<MonoidW, R, W, S, (A, B)> listen <MonoidW, R, W, S, A, B> (RWS<MonoidW, R, W, S, A> self, Func<W, B> f) Source #

where MonoidW : struct, Monoid<W>

Listen is an action that executes the monad and adds its output to the value of the computation.

Parameters

type R

Environment type

type W

Writer type

type S

State type

type A

Bound value type

method RWS<MonoidW, R, W, S, A> censor <MonoidW, R, W, S, A> (RWS<MonoidW, R, W, S, A> self, Func<W, W> f) Source #

where MonoidW : struct, Monoid<W>

Censor is an action that executes the writer monad and applies the function f to its output, leaving the return value unchanged.

Parameters

type R

Environment type

type W

Writer type

type S

State type

type A

Bound value type

method RWS<MonoidW, R, W, S, Unit> tell <MonoidW, R, W, S, A> (W what) Source #

where MonoidW : struct, Monoid<W>

Censor is an action that executes the writer monad and applies the function f to its output, leaving the return value unchanged.

Parameters

type R

Environment type

type W

Writer type

type S

State type

type A

Bound value type

method RWS<MonoidW, R, W, S, B> bind <MonoidW, R, W, S, A, B> (RWS<MonoidW, R, W, S, A> self, Func<A, RWS<MonoidW, R, W, S, B>> f) Source #

where MonoidW : struct, Monoid<W>

method RWS<MonoidW, R, W, S, B> map <MonoidW, R, W, S, A, B> (RWS<MonoidW, R, W, S, A> self, Func<A, B> f) Source #

where MonoidW : struct, Monoid<W>

method RWS<MonoidW, R, W, S, A> filter <MonoidW, R, W, S, A> (RWS<MonoidW, R, W, S, A> self, Func<A, bool> pred) Source #

where MonoidW : struct, Monoid<W>

method RWS<MonoidW, R, W, S, Unit> iter <MonoidW, R, W, S, A> (RWS<MonoidW, R, W, S, A> self, Action<A> action) Source #

where MonoidW : struct, Monoid<W>