LanguageExt.Core

LanguageExt.Core Monads Alternative Monads FinT

Contents

record FinT <M, A> (K<M, Fin<A>> runFin) Source #

where M : Monad<M>

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

Parameters

type M

Given monad trait

type A

Bound value type

param runFin

Transducer that represents the transformer operation

Properties

property K<M, bool> IsSucc Source #

Is the FinT in a Succ state?

property K<M, bool> IsFail Source #

Is the FinT in a Fail state?

Methods

method FinT<M, A> Succ (A value) Source #

Lift a pure value into the monad-transformer

Parameters

param value

Value to lift

returns

FinT

method FinT<M, A> Fail (Error value) Source #

Lift a fail value into the monad-transformer

Parameters

param value

Value to lift

returns

FinT

method FinT<M, A> Lift (Pure<A> pure) Source #

Lifts a given monad into the transformer

Parameters

param pure

Monad to lift

returns

FinT

method FinT<M, A> Lift (Fin<A> ma) Source #

Lifts a given monad into the transformer

Parameters

param ma

Monad to lift

returns

FinT

method FinT<M, A> Lift (Fail<Error> fail) Source #

Lifts a given monad into the transformer

Parameters

param fail

Monad to lift

returns

FinT

method FinT<M, A> Lift (Error fail) Source #

Lifts a given monad into the transformer

Parameters

param fail

Fail value

returns

FinT

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

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

FinT

method FinT<M, A> Lift (K<M, Fin<A>> monad) Source #

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

FinT

method FinT<M, A> LiftIO (IO<A> monad) Source #

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

FinT

method FinT<M, A> LiftIO (IO<Fin<A>> monad) Source #

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

FinT

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

Invokes the Succ or Fail function depending on the state of the FinT

Parameters

type B

Return type

param Fail

Function to invoke if in a Fail state

param Succ

Function to invoke if in a Succ state

returns

The return value of the invoked function

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

Invokes the Succ or Fail function depending on the state of the FinT

Parameters

param Succ

Action to invoke if in a Succ state

param Fail

Action to invoke if in a Fail state

returns

Unit

method K<M, A> IfFail (Func<A> Fail) Source #

Executes the Fail function if the Fin is in a Fail state. Returns the Succ value if the Fin is in a Succ state.

Parameters

param Fail

Function to generate a Succ value if in the Fail state

returns

Returns an unwrapped Succ value

method K<M, A> IfFail (Func<Error, A> f) Source #

Executes the f function if the Fin is in a Fail state. Returns the Succ value if the Fin is in a Succ state.

Parameters

param f

Function to generate a Succ value if in the Fail state

returns

Returns an unwrapped Succ value

method K<M, A> IfFail (A value) Source #

Returns the value if the Fin is in a Fail state. Returns the Succ value if the Fin is in a Succ state.

Parameters

param value

Value to return if in the Fail state

returns

Returns an unwrapped Succ value

method K<M, Unit> IfFail (Action<Error> Fail) Source #

Executes the Fail action if the Fin is in a Fail state.

Parameters

param Fail

Function to generate a Succ value if in the Fail state

returns

Returns an unwrapped Succ value

method K<M, Unit> IfSucc (Action<A> Succ) Source #

Invokes the Succ action if the Fin is in a Succ state, otherwise does nothing

Parameters

param Succ

Action to invoke

returns

Unit

method K<M, Error> IfSucc (Error fail) Source #

Returns the fail value if the Fin is in a Succ state. Returns the Fail value if the Fin is in a Fail state.

Parameters

param fail

Value to return if in the Succ state

returns

Returns an unwrapped Fail value

method K<M, Error> IfSucc (Func<Error> Succ) Source #

Returns the result of Succ() if the Fin is in a Succ state. Returns the Fail value if the Fin is in a Fail state.

Parameters

param Succ

Function to generate a Fail value if in the Succ state

returns

Returns an unwrapped Fail value

method K<M, Error> IfSucc (Func<A, Error> f) Source #

Returns the result of f if the Fin is in a Succ state. Returns the Fail value if the Fin is in a Fail state.

Parameters

param f

Function to generate a Fail value if in the Succ state

returns

Returns an unwrapped Fail value

method FinT<M1, B> MapT <M1, B> (Func<K<M, Fin<A>>, K<M1, Fin<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 FinT<M, B> MapM <B> (Func<K<M, A>, K<M, B>> f) Source #

Maps the given monad

Parameters

param f

Mapping function

method FinT<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

FinT

method FinT<M, A> MapFail (Func<Error, Error> f) Source #

Maps the Error value

Parameters

type B

Target bound value type

param f

Mapping function

returns

FinT

method FinT<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

FinT

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

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

FinT

method FinT<M, B> Bind <B> (Func<A, Fin<B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

FinT

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

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

FinT

method FinT<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

FinT

method FinT<M, B> Bind <B> (Func<A, Pure<B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

FinT

method FinT<M, B> Bind <B> (Func<A, Fail<Error>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

FinT

method FinT<M, B> BiBind <B> (Func<Error, FinT<M, B>> Fail, Func<A, FinT<M, B>> Succ) Source #

Monad bi-bind operation

Parameters

type B

Target bound value type

param Fail

Fail state mapping function

param Succ

Fail state mapping function

returns

FinT

method FinT<M, A> BindFail (Func<Error, FinT<M, A>> Fail) Source #

Monad bi-bind operation

Parameters

param Fail

Fail state mapping function

returns

FinT

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

FinT

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

FinT

method FinT<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

FinT

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

FinT

method FinT<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

FinT

method FinT<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

FinT

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

method EitherT<Error, M, A> ToEither () Source #

method ValidationT<Error, M, A> ToValidation () Source #

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

method StreamT<M, Error> FailToStream () Source #

Operators

operator >> (FinT<M, A> lhs, FinT<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 >> (FinT<M, A> lhs, K<FinT<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 >> (FinT<M, A> lhs, FinT<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 >> (FinT<M, A> lhs, K<FinT<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 + (FinT<M, A> lhs, FinT<M, A> rhs) Source #

operator + (K<FinT<M>, A> lhs, FinT<M, A> rhs) Source #

operator + (FinT<M, A> lhs, K<FinT<M>, A> rhs) Source #

operator + (FinT<M, A> lhs, A rhs) Source #

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

operator + (FinT<M, A> ma, Fail<Error> mb) Source #

operator + (FinT<M, A> ma, Fail<Exception> mb) Source #

operator | (FinT<M, A> lhs, FinT<M, A> rhs) Source #

operator | (K<FinT<M>, A> lhs, FinT<M, A> rhs) Source #

operator | (FinT<M, A> lhs, K<FinT<M>, A> rhs) Source #

operator | (FinT<M, A> lhs, A rhs) Source #

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

operator | (FinT<M, A> ma, Fail<Error> mb) Source #

operator | (FinT<M, A> ma, Fail<Exception> mb) Source #

operator | (FinT<M, A> ma, Error mb) Source #

operator | (FinT<M, A> ma, CatchM<Error, FinT<M>, A> mb) Source #

class FinTExtensions Source #

Either monad extensions

Methods

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

where M : Monad<M>

method K<M, Fin<A>> Run <M, A> (this K<FinT<M>, A> ma) Source #

where M : Monad<M>

Runs the FinT exposing the outer monad with an inner wrapped Fin

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

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

method FinT<IO, A> ToIO <M, A> (this Task<Fin<A>> ma) Source #

where M : Monad<M>

Lift the task

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

where M : Monad<M>

Monadic join

method FinT<M, C> SelectMany <M, A, B, C> ( this K<M, A> ma, Func<A, K<FinT<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 FinT<M, C> SelectMany <M, A, B, C> ( this K<M, A> ma, Func<A, FinT<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<Error>> Fails <M, A> (this IEnumerable<FinT<M, A>> self) Source #

where M : Monad<M>

Extracts from a sequence of 'Fin' transformers all the 'Fail' values. The 'Fail' elements are extracted in order.

Parameters

type A

Success value type

param self

Sequence of Fin transformers

returns

A sequence of errors

method K<M, Seq<Error>> Fails <M, R> (this Seq<FinT<M, R>> self) Source #

where M : Monad<M>

Extracts from a sequence of 'Fin' transformers all the 'Fail' values. The 'Fail' elements are extracted in order.

Parameters

type A

Success value type

param self

Sequence of Fin transformers

returns

A sequence of errors

method K<M, Seq<A>> Succs <M, A> (this IEnumerable<FinT<M, A>> self) Source #

where M : Monad<M>

Extracts from a sequence of 'Fin' transformers all the 'Succ' values. The 'Succ' elements are extracted in order.

Parameters

type A

Success value type

param self

Sequence of Fin transformers

returns

A sequence of success values

method K<M, Seq<A>> Succs <M, A> (this Seq<FinT<M, A>> self) Source #

where M : Monad<M>

Extracts from a sequence of 'Fin' transformers all the 'Succ' values. The 'Succ' elements are extracted in order.

Parameters

type A

Success value type

param self

Sequence of Fin transformers

returns

A sequence of success values

method K<M, (Seq<Error> Lefts, Seq<A> Rights)> Partition <M, A> (this Seq<FinT<M, A>> self) Source #

where M : Monad<M>

Partitions a sequence of 'FinT' transformers into two sequences. All the 'Fail' elements are extracted, in order, to the first component of the output. Similarly, the 'Succ' elements are extracted to the second component of the output.

Parameters

type A

Success type

param self

Sequence of Fin transformers

returns

A tuple containing a sequence of Fail and a sequence of Succ

method K<M, (Seq<Error> Lefts, Seq<A> Rights)> Partition <M, A> (this IEnumerable<FinT<M, A>> self) Source #

where M : Monad<M>

Partitions a sequence of 'FinT' transformers into two sequences. All the 'Fail' elements are extracted, in order, to the first component of the output. Similarly, the 'Succ' elements are extracted to the second component of the output.

Parameters

type A

Success type

param self

Sequence of Fin transformers

returns

A tuple containing a sequence of Fail and a sequence of Succ

class FinTExtensions Source #

Methods

method FinT<M, B> Map <M, A, B> (this Func<A, B> f, K<FinT<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 FinT<M, B> Map <M, A, B> (this Func<A, B> f, FinT<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 FinT<M, B> Action <M, A, B> (this FinT<M, A> ma, FinT<M, B> mb) Source #

where M : Monad<M>

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

method FinT<M, B> Apply <M, A, B> (this FinT<M, Func<A, B>> mf, K<FinT<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 FinT<M, B> Apply <M, A, B> (this K<FinT<M>, Func<A, B>> mf, K<FinT<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 FinT <M> Source #

Methods

method FinT<M, A> Succ <A> (A value) Source #

method FinT<M, A> Fail <A> (Error value) Source #

method FinT<M, A> lift <A> (Fin<A> ma) Source #

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

method FinT<M, A> lift <A> (Fail<Error> ma) Source #

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

class FinT Source #

Methods

method FinT<M, B> bind <M, A, B> (FinT<M, A> ma, Func<A, FinT<M, B>> f) Source #

where M : Monad<M>

method FinT<M, B> map <M, A, B> (Func<A, B> f, FinT<M, A> ma) Source #

where M : Monad<M>

method FinT<M, A> Succ <M, A> (A value) Source #

where M : Monad<M>

method FinT<M, A> Fail <M, A> (Error value) Source #

where M : Monad<M>

method FinT<M, A> lift <M, A> (Fin<A> ma) Source #

where M : Monad<M>

method FinT<M, A> lift <M, A> (Either<Error, A> ma) Source #

where M : Monad<M>

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

where M : Monad<M>

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

where M : Monad<M>

method FinT<M, A> lift <M, A> (Fail<Error> ma) Source #

where M : Monad<M>

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

where M : Monad<M>

method K<M, B> match <M, A, B> (FinT<M, A> ma, Func<A, B> Succ, Func<Error, B> Fail) Source #

where M : Monad<M>

class FinT <M> Source #

where M : Monad<M>

Trait implementation for FinT

Parameters

type M

Given monad trait

class Prelude Source #

Methods

method FinT<M, B> map <M, A, B> (Func<A, B> f, K<FinT<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 FinT<M, B> action <M, A, B> (K<FinT<M>, A> ma, K<FinT<M>, B> mb) Source #

where M : Monad<M>

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

method FinT<M, B> apply <M, A, B> (K<FinT<M>, Func<A, B>> mf, K<FinT<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