LanguageExt.Core

LanguageExt.Core Monads Alternative Monads EitherT

Contents

record EitherT <L, M, R> (K<M, Either<L, R>> runEither) Source #

where M : Monad<M>

EitherT monad transformer, which allows for either an L or R result value to be carried.

Parameters

type M

Given monad trait

type L

Left value type

type R

Bound value type

param runEither

Transducer that represents the transformer operation

Properties

property K<M, bool> IsRight Source #

Is the EitherT in a Right state?

property K<M, bool> IsLeft Source #

Is the EitherT in a Left state?

Methods

method EitherT<L, M, R> Right (R value) Source #

Lift a pure value into the monad-transformer

Parameters

param value

Value to lift

returns

EitherT

method EitherT<L, M, R> Left (L value) Source #

Lift a fail value into the monad-transformer

Parameters

param value

Value to lift

returns

EitherT

method EitherT<L, M, R> Lift (Pure<R> pure) Source #

Lifts a given monad into the transformer

Parameters

param pure

Monad to lift

returns

EitherT

method EitherT<L, M, R> Lift (Either<L, R> either) Source #

Lifts a given monad into the transformer

Parameters

param either

Monad to lift

returns

EitherT

method EitherT<L, M, R> Lift (Fail<L> fail) Source #

Lifts a given monad into the transformer

Parameters

param fail

Monad to lift

returns

EitherT

method EitherT<L, M, R> Lift (K<M, R> monad) Source #

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

EitherT

method EitherT<L, M, R> Lift (K<M, Either<L, R>> monad) Source #

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

EitherT

method EitherT<L, M, R> LiftIO (IO<R> monad) Source #

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

EitherT

method EitherT<L, M, R> LiftIO (IO<Either<L, R>> monad) Source #

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

EitherT

method K<M, B> Match <B> (Func<L, B> Left, Func<R, B> Right) Source #

Invokes the Right or Left function depending on the state of the Either

Parameters

type B

Return type

param Left

Function to invoke if in a Left state

param Right

Function to invoke if in a Right state

returns

The return value of the invoked function

method K<M, Unit> Match (Action<L> Left, Action<R> Right) Source #

Invokes the Right or Left action depending on the state of the Either

Parameters

param Right

Action to invoke if in a Right state

param Left

Action to invoke if in a Left state

returns

Unit

method K<M, R> IfLeft (Func<R> Left) Source #

Executes the Left function if the Either is in a Left state. Returns the Right value if the Either is in a Right state.

Parameters

param Left

Function to generate a Right value if in the Left state

returns

Returns an unwrapped Right value

method K<M, R> IfLeft (Func<L, R> leftMap) Source #

Executes the leftMap function if the Either is in a Left state. Returns the Right value if the Either is in a Right state.

Parameters

param leftMap

Function to generate a Right value if in the Left state

returns

Returns an unwrapped Right value

method K<M, R> IfLeft (R rightValue) Source #

Returns the rightValue if the Either is in a Left state. Returns the Right value if the Either is in a Right state.

Parameters

param rightValue

Value to return if in the Left state

returns

Returns an unwrapped Right value

method K<M, Unit> IfLeft (Action<L> Left) Source #

Executes the Left action if the Either is in a Left state.

Parameters

param Left

Function to generate a Right value if in the Left state

returns

Returns an unwrapped Right value

method K<M, Unit> IfRight (Action<R> Right) Source #

Invokes the Right action if the Either is in a Right state, otherwise does nothing

Parameters

param Right

Action to invoke

returns

Unit

method K<M, L> IfRight (L leftValue) Source #

Returns the leftValue if the Either is in a Right state. Returns the Left value if the Either is in a Left state.

Parameters

param leftValue

Value to return if in the Left state

returns

Returns an unwrapped Left value

method K<M, L> IfRight (Func<L> Right) Source #

Returns the result of Right() if the Either is in a Right state. Returns the Left value if the Either is in a Left state.

Parameters

param Right

Function to generate a Left value if in the Right state

returns

Returns an unwrapped Left value

method K<M, L> IfRight (Func<R, L> rightMap) Source #

Returns the result of rightMap if the Either is in a Right state. Returns the Left value if the Either is in a Left state.

Parameters

param rightMap

Function to generate a Left value if in the Right state

returns

Returns an unwrapped Left value

method EitherT<L, M1, B> MapT <M1, B> (Func<K<M, Either<L, R>>, K<M1, Either<L, B>>> f) Source #

where M1 : Monad<M1>

Maps the bound monad

Parameters

type M1

Target monad type

type B

Target bound value type

param f

Mapping function

returns

Mapped monad

method EitherT<L, M, B> MapM <B> (Func<K<M, R>, K<M, B>> f) Source #

Maps the given monad

Parameters

param f

Mapping function

method EitherT<L, M, B> Map <B> (Func<R, B> f) Source #

Maps the bound value

Parameters

type B

Target bound value type

param f

Mapping function

returns

EitherT

method EitherT<B, M, R> MapLeft <B> (Func<L, B> f) Source #

Maps the left value

Parameters

type B

Target bound value type

param f

Mapping function

returns

EitherT

method EitherT<L, M, B> Select <B> (Func<R, B> f) Source #

Maps the bound value

Parameters

type B

Target bound value type

param f

Mapping transducer

returns

EitherT

method EitherT<L, M, B> Bind <B> (Func<R, K<EitherT<L, M>, B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

EitherT

method EitherT<L, M, B> Bind <B> (Func<R, Either<L, B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

EitherT

method EitherT<L, M, B> Bind <B> (Func<R, EitherT<L, M, B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

EitherT

method EitherT<L, M, B> Bind <B> (Func<R, IO<B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

EitherT

method EitherT<L, M, B> Bind <B> (Func<R, Pure<B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

EitherT

method EitherT<L, M, B> Bind <B> (Func<R, Fail<L>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

EitherT

method EitherT<L, M, B> BiBind <B> (Func<L, EitherT<L, M, B>> Left, Func<R, EitherT<L, M, B>> Right) Source #

Monad bi-bind operation

Parameters

type B

Target bound value type

param Left

Left state mapping function

param Right

Left state mapping function

returns

EitherT

method EitherT<L, M, R> BindLeft (Func<L, EitherT<L, M, R>> Left) Source #

Monad bi-bind operation

Parameters

param Left

Left state mapping function

returns

EitherT

method EitherT<L, M, C> SelectMany <B, C> (Func<R, K<EitherT<L, M>, B>> bind, Func<R, 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

EitherT

method EitherT<L, M, C> SelectMany <B, C> (Func<R, EitherT<L, M, B>> bind, Func<R, 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

EitherT

method EitherT<L, M, C> SelectMany <B, C> (Func<R, K<M, B>> bind, Func<R, 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

EitherT

method EitherT<L, M, C> SelectMany <B, C> (Func<R, Either<L, B>> bind, Func<R, 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

EitherT

method EitherT<L, M, C> SelectMany <B, C> (Func<R, Pure<B>> bind, Func<R, 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

EitherT

method EitherT<L, M, C> SelectMany <B, C> (Func<R, IO<B>> bind, Func<R, 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

EitherT

method EitherT<L, M, C> SelectMany <C> (Func<R, Guard<L, Unit>> bind, Func<R, 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

EitherT

method OptionT<M, R> ToOption () Source #

method StreamT<M, R> ToStream () Source #

method StreamT<M, L> LeftToStream () Source #

Operators

operator >> (EitherT<L, M, R> lhs, EitherT<L, M, R> 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 >> (EitherT<L, M, R> lhs, K<EitherT<L, M>, R> 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 >> (EitherT<L, M, R> lhs, EitherT<L, 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 >> (EitherT<L, M, R> lhs, K<EitherT<L, 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 | (EitherT<L, M, R> lhs, EitherT<L, M, R> rhs) Source #

operator | (K<EitherT<L, M>, R> lhs, EitherT<L, M, R> rhs) Source #

operator | (EitherT<L, M, R> lhs, K<EitherT<L, M>, R> rhs) Source #

operator | (EitherT<L, M, R> ma, R b) Source #

operator | (EitherT<L, M, R> ma, Pure<R> mb) Source #

operator | (EitherT<L, M, R> ma, Fail<L> mb) Source #

operator | (EitherT<L, M, R> ma, L mb) Source #

operator | (EitherT<L, M, R> ma, CatchM<L, EitherT<L, M>, R> mb) Source #

class EitherTExtensions Source #

EitherT monad-transformer extensions

Methods

method EitherT<L, M, A> As <L, M, A> (this K<EitherT<L, M>, A> ma) Source #

where M : Monad<M>

method FinT<M, A> ToFin <M, A> (this K<EitherT<Error, M>, A> ma) Source #

where M : Monad<M>

method K<M, Either<L, A>> Run <L, M, A> (this K<EitherT<L, M>, A> ma) Source #

where M : Monad<M>

Runs the EitherT exposing the outer monad with an inner wrapped Either

method EitherT<L, IO, A> Flatten <L, A> (this Task<EitherT<L, IO, A>> tma) Source #

Get the outer task and wrap it up in a new IO within the EitherT IO

method EitherT<L, IO, A> ToIO <L, A> (this Task<Either<L, A>> ma) Source #

Lift the task

method EitherT<L, M, A> Flatten <L, M, A> (this EitherT<L, M, EitherT<L, M, A>> mma) Source #

where M : Monad<M>

Monadic join

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

where M : Monad<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

EitherT

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

where M : Monad<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

EitherT

method K<M, Seq<L>> Lefts <L, M, R> (this IEnumerable<EitherT<L, M, R>> self) Source #

where M : Monad<M>

Extracts from a list of 'Either' all the 'Left' elements. All the 'Left' elements are extracted in order.

Parameters

type L

Left

type R

Right

param self

Either list

returns

An enumerable of L

method K<M, Seq<L>> Lefts <L, M, R> (this Seq<EitherT<L, M, R>> self) Source #

where M : Monad<M>

Extracts from a list of 'Either' all the 'Left' elements. All the 'Left' elements are extracted in order.

Parameters

type L

Left

type R

Right

param self

Either list

returns

An enumerable of L

method K<M, Seq<R>> Rights <L, M, R> (this IEnumerable<EitherT<L, M, R>> self) Source #

where M : Monad<M>

Extracts from a list of 'Either' all the 'Right' elements. All the 'Right' elements are extracted in order.

Parameters

type L

Left

type R

Right

param self

Either list

returns

An enumerable of L

method K<M, Seq<R>> Rights <L, M, R> (this Seq<EitherT<L, M, R>> self) Source #

where M : Monad<M>

Extracts from a list of 'Either' all the 'Right' elements. All the 'Right' elements are extracted in order.

Parameters

type L

Left

type R

Right

param self

Either list

returns

An enumerable of L

method K<M, (Seq<L> Lefts, Seq<R> Rights)> Partition <L, M, R> (this Seq<EitherT<L, M, R>> self) Source #

where M : Monad<M>

Partitions a list of 'Either' into two lists. All the 'Left' elements are extracted, in order, to the first component of the output. Similarly, the 'Right' elements are extracted to the second component of the output.

Parameters

type L

Left

type R

Right

param self

Either list

returns

A tuple containing the enumerable of L and enumerable of R

method K<M, (Seq<L> Lefts, Seq<R> Rights)> Partition <L, M, R> (this IEnumerable<EitherT<L, M, R>> self) Source #

where M : Monad<M>

Partitions a list of 'Either' into two lists. All the 'Left' elements are extracted, in order, to the first component of the output. Similarly, the 'Right' elements are extracted to the second component of the output.

Parameters

type L

Left

type R

Right

param self

Either list

returns

A tuple containing the enumerable of L and enumerable of R

class EitherTExtensions Source #

Methods

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

where M : Monad<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 EitherT<L, M, B> Map <L, M, A, B> (this Func<A, B> f, EitherT<L, M, A> ma) Source #

where M : Monad<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 EitherT<L, M, B> Action <L, M, A, B> (this EitherT<L, M, A> ma, K<EitherT<L, M>, B> mb) Source #

where M : Monad<M>

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

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

where M : Monad<M>

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

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

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

where M : Monad<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 EitherT <L, M> Source #

Methods

method EitherT<L, M, A> Right <A> (A value) Source #

method EitherT<L, M, A> Left <A> (L value) Source #

method EitherT<L, M, A> lift <A> (Either<L, A> ma) Source #

method EitherT<L, M, A> lift <A> (Pure<A> ma) Source #

method EitherT<L, M, A> lift <A> (Fail<L> ma) Source #

method EitherT<L, M, A> liftIO <A> (IO<A> ma) Source #

class EitherT Source #

Methods

method EitherT<L, M, A> Right <L, M, A> (A value) Source #

where M : Monad<M>

method EitherT<L, M, A> Left <L, M, A> (L value) Source #

where M : Monad<M>

method EitherT<L, M, A> lift <L, M, A> (Either<L, A> ma) Source #

where M : Monad<M>

method EitherT<L, M, A> lift <L, M, A> (K<M, A> ma) Source #

where M : Monad<M>

method EitherT<L, M, A> lift <L, M, A> (Pure<A> ma) Source #

where M : Monad<M>

method EitherT<L, M, A> lift <L, M, A> (Fail<L> ma) Source #

where M : Monad<M>

method EitherT<L, M, A> liftIO <L, M, A> (K<IO, A> ma) Source #

where M : Monad<M>

method EitherT<L, M, A> liftIO <L, M, A> (IO<Either<L, A>> ma) Source #

where M : Monad<M>

method K<M, B> match <L, M, A, B> (EitherT<L, M, A> ma, Func<L, B> Left, Func<A, B> Right) Source #

where M : Monad<M>

class EitherT <L, M> Source #

where M : Monad<M>

Trait implementation for EitherT

Parameters

type M

Given monad trait

class Prelude Source #

Methods

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

where M : Monad<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 EitherT<L, M, B> action <L, M, A, B> (K<EitherT<L, M>, A> ma, K<EitherT<L, M>, B> mb) Source #

where M : Monad<M>

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

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

where M : Monad<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