LanguageExt.Core

LanguageExt.Core Monads State and Environment Monads Writer WriterT

Contents

record WriterT <W, M, A> (Func<W, K<M, (A Value, W Output)>> runWriter) Source #

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

WriterT 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 WriterT<W, M, (A Value, W Output)> Listen Source #

Writes an item and returns a value at the same time

Methods

method WriterT<W, M, A> Pure (A value) Source #

Lift a pure value into the monad-transformer

Parameters

param value

Value to lift

returns

WriterT

method WriterT<W, M, A> Write ((A Value, W Output) result) Source #

Construct a writer computation from a (result, output) pair.

The inverse of Run()

Parameters

param result

Result / Output pair

method WriterT<W, M, A> Write (A value, W output) Source #

Construct a writer computation from a (result, output) pair.

The inverse of Run()

Parameters

param result

Result / Output pair

method WriterT<W, M, (A Value, B Output)> Listens <B> (Func<W, B> f) Source #

Listens executes the action and adds the result of applying f to the output to the value of the computation.

method WriterT<W, M, A> Censor (Func<W, W> f) Source #

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

method WriterT<W, M, A> Lift (Pure<A> monad) Source #

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

WriterT

method WriterT<W, M, A> Lift (K<M, A> monad) Source #

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

WriterT

method WriterT<W, M, A> Lift (Func<A> f) Source #

Lifts a function into the transformer

Parameters

param f

Function to lift

returns

WriterT

method WriterT<W, M, A> LiftIO (IO<A> ma) Source #

Lifts a 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

WriterT

method WriterT<W, M1, B> MapT <M1, B> (Func<K<M, (A Value, W Output)>, K<M1, (B Value, W Output)>> 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

WriterT

method WriterT<W, 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 WriterT<W, 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

WriterT

method WriterT<W, 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

WriterT

method WriterT<W, M, B> Bind <B> (Func<A, K<WriterT<W, M>, B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

WriterT

method WriterT<W, M, B> Bind <B> (Func<A, WriterT<W, M, B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

WriterT

method WriterT<W, M, Unit> Bind <B> (Func<A, Tell<W>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

WriterT

method WriterT<W, 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

WriterT

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

WriterT

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

WriterT

method WriterT<W, 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

WriterT

method WriterT<W, 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

WriterT

method WriterT<W, M, C> SelectMany <C> (Func<A, Tell<W>> 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

WriterT

method WriterT<W, 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

WriterT

method K<M, (A Value, W Output)> Run () Source #

Run the writer

Parameters

returns

Bound monad

Operators

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

operator | (WriterT<W, M, A> ma, K<WriterT<W, M>, A> mb) Source #

operator | (WriterT<W, M, A> ma, Pure<A> mb) Source #

operator | (Pure<A> ma, WriterT<W, M, A>mb) Source #

operator | (IO<A> ma, WriterT<W, M, A> mb) Source #

operator | (WriterT<W, M, A> ma, IO<A> mb) Source #

operator + (K<WriterT<W, M>, A> ma, WriterT<W, M, A> mb) Source #

operator + (WriterT<W, M, A> ma, K<WriterT<W, M>, A> mb) Source #

operator + (WriterT<W, M, A> ma, Pure<A> mb) Source #

operator + (Pure<A> ma, WriterT<W, M, A>mb) Source #

operator + (IO<A> ma, WriterT<W, M, A> mb) Source #

operator + (WriterT<W, M, A> ma, IO<A> mb) Source #

class WriterTExtensions Source #

Methods

method WriterT<W, M, A> As <W, M, A> (this K<WriterT<W, M>, A> ma) Source #

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

method K<M, (A Value, W Output)> Run <W, M, A> (this K<WriterT<W, M>, A> ma) Source #

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

Run the writer

Parameters

returns

Bound monad

method K<M, (A Value, W Output)> Run <W, M, A> (this K<WriterT<W, M>, A> ma, W initial) Source #

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

Run the writer

Parameters

returns

Bound monad

method WriterT<W, M, A> Flatten <W, M, A> (this WriterT<W, M, WriterT<W, M, A>> mma) Source #

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

Monadic join

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

where W : Monoid<W>
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 WriterT<W, M, C> SelectMany <W, M, A, B, C> ( this K<M, A> ma, Func<A, WriterT<W, M, B>> bind, Func<A, B, C> project) Source #

where W : Monoid<W>
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 WriterTExtensions Source #

Methods

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

where W : Monoid<W>
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 WriterT<W, M, B> Map <W, M, A, B> (this Func<A, B> f, WriterT<W, M, A> ma) Source #

where W : Monoid<W>
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 WriterT<W, M, B> Action <W, M, A, B> (this WriterT<W, M, A> ma, K<WriterT<W, M>, B> mb) Source #

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

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

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

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

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

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

where W : Monoid<W>
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 WriterT<W, M, B> Apply <W, M, A, B> (this K<WriterT<W, M>, Func<A, B>> mf, K<WriterT<W, M>, A> ma) Source #

where W : Monoid<W>
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 WriterT <W> Source #

where W : Monoid<W>

MonadWriterT trait implementation for WriterT

Parameters

type S

State environment type

type M

Given monad trait

Methods

method WriterT<W, M, A> lift <M, A> (K<M, A> ma) Source #

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

class WriterT <W, M> Source #

MonadWriterT trait implementation for WriterT

Parameters

type S

State environment type

type M

Given monad trait

Methods

method WriterT<W, M, A> pure <A> (A value) Source #

method WriterT<W, M, A> liftIO <A> (IO<A> effect) Source #

Lifts a given monad into the transformer

Parameters

param effect

Monad to lift

returns

WriterT

class WriterT Source #

MonadWriterT trait implementation for WriterT

Parameters

type S

State environment type

type M

Given monad trait

Methods

method WriterT<W, M, A> pure <W, M, A> (A value) Source #

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

method WriterT<W, M, A> lift <W, M, A> (K<M, A> ma) Source #

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

method WriterT<W, M, A> liftIO <W, M, A> (IO<A> effect) Source #

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

Lifts a given monad into the transformer

Parameters

param effect

Monad to lift

returns

WriterT

method WriterT<W, M, Unit> tell <W, M> (W item) Source #

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

Tell is an action that produces the writer output

Parameters

type W

Writer type

param item

Item to tell

returns

Structure with the told item

method WriterT<W, M, A> write <W, M, A> ((A, W) item) Source #

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

Writes an item and returns a value at the same time

method WriterT<W, M, A> write <W, M, A> (A value, W item) Source #

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

Writes an item and returns a value at the same time

method WriterT<W, M, A> pass <W, M, A> (WriterT<W, M, (A Value, Func<W, W> Function)> action) Source #

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

pass is an action that executes the action, which returns a value and a function; it then returns the value with the output having been applied to the function.

method WriterT<W, M, (A Value, W Output)> listen <W, M, A> (WriterT<W, M, A> ma) Source #

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

listen executes the action ma and adds the result of applying f to the output to the value of the computation.

method WriterT<W, M, (A Value, B Output)> listens <W, M, A, B> (Func<W, B> f, WriterT<W, M, A> ma) Source #

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

listens executes the action ma and adds the result of applying f to the output to the value of the computation.

method WriterT<W, M, A> censor <W, M, A> (Func<W, W> f, WriterT<W, M, A> ma) Source #

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

censor executes the action ma and applies the function f to its output, leaving the return value unchanged.

class WriterT <W, M> Source #

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

MonadStateT trait implementation for StateT

Parameters

type S

State environment type

type M

Given monad trait

class Prelude Source #

Methods

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

where W : Monoid<W>
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 WriterT<W, M, B> action <W, M, A, B> (K<WriterT<W, M>, A> ma, K<WriterT<W, M>, B> mb) Source #

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

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

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

where W : Monoid<W>
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