LanguageExt.Core

LanguageExt.Core Monads State and Environment Monads Writer Writer

Contents

record Writer <W, A> (Func<W, (A Value, W Output)> runWriter) Source #

where W : Monoid<W>

Writer 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

Methods

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

Lift a pure value into the monad-transformer

Parameters

param value

Value to lift

returns

Writer

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

Writes an item and returns a value at the same time

method Writer<W, (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 Writer<W, 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 Writer<W, A> Lift (Pure<A> monad) Source #

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

Writer

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

Lifts a function into the transformer

Parameters

param f

Function to lift

returns

Writer

method Writer<W, B> Map <B> (Func<A, B> f) Source #

Maps the bound value

Parameters

type B

Target bound value type

param f

Mapping function

returns

Writer

method Writer<W, B> Select <B> (Func<A, B> f) Source #

Maps the bound value

Parameters

type B

Target bound value type

param f

Mapping transducer

returns

Writer

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

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

Writer

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

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

Writer

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

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

Writer

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

Writer

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

Writer

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

Writer

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

Writer

method (A Value, W Output) Run () Source #

Run the writer

Parameters

returns

Bound monad

Operators

operator >> (Writer<W, A> lhs, Writer<W, 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 >> (Writer<W, A> lhs, K<Writer<W>, 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 >> (Writer<W, A> lhs, Writer<W, 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 >> (Writer<W, A> lhs, K<Writer<W>, 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 WriterExtensions Source #

Methods

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

where W : Monoid<W>

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

where W : Monoid<W>

Run the writer

Parameters

returns

Bound monad

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

where W : Monoid<W>

Run the writer

Parameters

returns

Bound monad

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

where W : Monoid<W>

Monadic join

class WriterExtensions Source #

Methods

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

where W : Monoid<W>

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

where W : Monoid<W>

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

where W : Monoid<W>

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

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

where W : Monoid<W>

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

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

where W : Monoid<W>

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

where W : Monoid<W>

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 Writer <W> Source #

Methods

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

class Writer Source #

Methods

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

where W : Monoid<W>

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

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 Writer<W, A> write <W, A> ((A, W) item) Source #

where W : Monoid<W>

Writes an item and returns a value at the same time

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

where W : Monoid<W>

Writes an item and returns a value at the same time

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

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 Writer<W, (A Value, W Output)> listen <W, A> (Writer<W, A> ma) Source #

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 Writer<W, (A Value, B Output)> listens <W, A, B> (Func<W, B> f, Writer<W, A> ma) Source #

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 Writer<W, A> censor <W, A> (Func<W, W> f, Writer<W, A> ma) Source #

where W : Monoid<W>

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

class Writer <W> Source #

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 Writer<W, Unit> tell <W> (W item) Source #

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 Writer<W, A> write <W, A> ((A, W) item) Source #

where W : Monoid<W>

Writes an item and returns a value at the same time

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

where W : Monoid<W>

Writes an item and returns a value at the same time

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

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 Writer<W, (A Value, W Output)> listen <W, A> (Writer<W, A> ma) Source #

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 Writer<W, (A Value, B Output)> listens <W, A, B> (Func<W, B> f, Writer<W, A> ma) Source #

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 Writer<W, A> censor <W, A> (Func<W, W> f, Writer<W, A> ma) Source #

where W : Monoid<W>

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

class Prelude Source #

Methods

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

where W : Monoid<W>

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 Writer<W, B> action <W, A, B> (K<Writer<W>, A> ma, K<Writer<W>, B> mb) Source #

where W : Monoid<W>

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

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

where W : Monoid<W>

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