LanguageExt.Core

LanguageExt.Core Type Classes Monad

Contents

interface Monad <MA, A> Source #

Monad type-class

Parameters

type MA

The data-type to make monadic

type A

The data-type bound value

interface Monad <Env, Out, MA, A> Source #

Monad type-class

Parameters

type Env

The input type to the monadic computation

type Out

The output type of the monadic computation

type MA

The data-type to make monadic

type A

The data-type bound value

class TypeClass Source #

Methods

method MA Return <MONAD, MA, A> (A x) Source #

where MONAD : struct, Monad<MA, A>

Monad return

Parameters

type A

Type of the bound monad value

param x

The bound monad value

returns

Monad of A

method MB traverse <MonadA, MonadB, MA, MB, A, B> (MA ma, Func<A, B> f) Source #

where MonadA : struct, Monad<Unit, Unit, MA, A>
where MonadB : struct, Monad<Unit, Unit, MB, B>

method MB traverse <MonadA, MonadB, MA, MB, A, B> (MA ma, Func<A, MB> f) Source #

where MonadA : struct, Monad<Unit, Unit, MA, A>
where MonadB : struct, Monad<Unit, Unit, MB, B>

method Func<Env, MB> traverse <Env, Out, MonadA, MonadB, MA, MB, A, B> (MA ma, Func<A, B> f) Source #

where MonadA : struct, Monad<Env, Out, MA, A>
where MonadB : struct, Monad<Env, Out, MB, B>

method Func<Env, MB> traverse <Env, Out, MonadA, MonadB, MA, MB, A, B> (MA ma, Func<A, MB> f) Source #

where MonadA : struct, Monad<Env, Out, MA, A>
where MonadB : struct, Monad<Env, Out, MB, B>

method MB bind <MONADA, MONADB, MA, MB, A, B> (MA ma, Func<A, MB> f) Source #

where MONADA : struct, Monad<MA, A>
where MONADB : struct, Monad<MB, B>

Monadic bind

Parameters

type B

Type of the bound return value

param ma

Monad to bind

param f

Bind function

returns

Monad of B

method MA fail <MONAD, MA, A> (Exception err = null) Source #

where MONAD : struct, Monad<MA, A>

Produce a failure value

method MB liftM <MONAD, FUNCTOR, MA, MB, A, B> (MA ma, Func<A, B> f) Source #

where FUNCTOR : struct, Functor<MA, MB, A, B>

Performs a map operation on the monad

Parameters

type B

The mapped type

param ma

Monad to map

param f

Mapping operation

returns

Mapped monad

method MD join <EQ, MONADA, MONADB, MONADD, MA, MB, MD, A, B, C, D> ( MA self, MB inner, Func<A, C> outerKeyMap, Func<B, C> innerKeyMap, Func<A, B, D> project) Source #

where EQ : struct, Eq<C>
where MONADA : struct, Monad<MA, A>
where MONADB : struct, Monad<MB, B>
where MONADD : struct, Monad<MD, D>

Monad join

method MC SelectMany <MONADA, MONADB, MONADC, MA, MB, MC, A, B, C> ( MA self, Func<A, MB> bind, Func<A, B, C> project) Source #

where MONADA : struct, Monad<MA, A>
where MONADB : struct, Monad<MB, B>
where MONADC : struct, Monad<MC, C>

Monadic bind and project

method IEnumerable<C> SelectMany <MONADA, MA, A, B, C> ( MA self, Func<A, IEnumerable<B>> bind, Func<A, B, C> project) Source #

where MONADA : struct, Monad<MA, A>

method Seq<C> SelectMany <MONADA, MA, A, B, C> ( MA self, Func<A, Seq<B>> bind, Func<A, B, C> project) Source #

where MONADA : struct, Monad<MA, A>

method MA mzero <MPLUS, MA, A> () Source #

where MPLUS : struct, Monad<MA, A>

Return monad 'zero'. None for Option, [] for Lst, ...

Parameters

type MA

Monad type

type A

Bound type

returns

Zero for the structure

method MA mplus <MPLUS, MA, A> (MA x, MA y) Source #

where MPLUS : struct, Monad<MA, A>

Return monad x 'plus' monad y

Note, this doesn't add the bound values, it works on the monad state itself.

For example with Option:

None   'plus' None   = None
Some a 'plus' None   = Some a
None   'plus' Some b = Some b
Some a 'plus' Some b = Some a

Parameters

type MA

Monad type

type A

Bound type

param x

Left hand side of the operation

param y

Right hand side of the operation

returns

x 'plus' y

method MA msum <MPLUS, MA, A> (params MA[] xs) Source #

where MPLUS : struct, Monad<MA, A>

Performs the following fold operation: fold(xs, mzero, mplus)

Parameters

type MA

Monad type

type A

Bound type

param xs

The monads to sum

returns

The summed monads

method MA msum <MPLUS, MA, A> (IEnumerable<MA> xs) Source #

where MPLUS : struct, Monad<MA, A>

Performs the following fold operation: fold(xs, mzero, mplus)

Parameters

type MA

Monad type

type A

Bound type

param xs

The monads to sum

returns

The summed monads

method MA filter <MPLUS, MA, A> (MA ma, Func<A, bool> pred) Source #

where MPLUS : struct, Monad<MA, A>

Filters the monad if the predicate doesn't hold

Parameters

type MA

Monad type

type A

Bound type

param ma

The monads filter

returns

The filtered (or not) monad