LanguageExt.Core

LanguageExt.Core Monads Alternative Monads Fin

The Fin monad supports either an Error or an A (success) value. It is functionally exactly the same as Either<Error, A>, it is a convenience type to avoid the generics pain of Either.

To construct a Fin:

Fin<int> ma = Pure(123);
Fin<int> mb = Fail(Error.New("Error!"));

Contents

Sub modules

Extensions
Operators
Trait

class Fin <A> Source #

Equivalent of Either〈Error, A〉 Called Fin because it is expected to be used as the concrete result of a computation

Properties

property bool IsSucc Source #

Is the structure in a Success state?

property bool IsFail Source #

Is the structure in a Fail state?

property Fin<A> Empty Source #

Monoid empty

Methods

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

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

Parameters

type B

Return type

param Succ

Function to invoke if in a Succ state

param Fail

Function to invoke if in a Fail state

returns

The return value of the invoked function

method ReadOnlySpan<Error> FailSpan () Source #

Empty span

method ReadOnlySpan<A> SuccSpan () Source #

Span of right value

method int CompareTo <OrdA> (Fin<A> other) Source #

where OrdA : Ord<A>

Compare this structure to another to find its relative ordering

method bool Equals <EqA> (Fin<A> other) Source #

where EqA : Eq<A>

Equality override

method bool Equals (Fin<A>? other) Source #

Equality override

method bool Equals (object? other) Source #

Equality override

method int GetHashCode <HashA> () Source #

where HashA : Hashable<A>

method int GetHashCode () Source #

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

Maps the value in the structure

Parameters

param f

Map function

returns

Mapped structure

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

Maps the value in the structure

Parameters

param f

Map function

returns

Mapped structure

method Fin<B> BiMap <B> (Func<A, B> Succ, Func<Error, Error> Fail) Source #

Bi-maps the structure

Parameters

returns

Mapped Either

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

Monadic bind

Parameters

type B

Resulting bound value

param f

Bind function

returns

Bound structure

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

Bi-bind. Allows mapping of both monad states

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

Bind if in a fail state

method int CompareTo (Fin<A>? other) Source #

method int CompareTo (object? obj) Source #

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

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

method A IfFail (A alternative) Source #

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

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

method Unit Iter (Action<A> Succ) Source #

method S Fold <S> (S state, Func<S, A, S> f) Source #

method S BiFold <S> (in S state, Func<S, A, S> Succ, Func<S, Error, S> Fail) Source #

method bool Exists (Func<A, bool> f) Source #

method bool ForAll (Func<A, bool> f) Source #

method K<F, Fin<B>> Traverse <F, B> (Func<A, K<F, B>> f) Source #

where F : Applicative<F>

Map each element of a structure to an action, evaluate these actions from left to right, and collect the results.

Parameters

type F

Applicative functor trait

type B

Bound value (output)

param f
param ta

Traversable structure

method K<M, Fin<B>> TraverseM <M, B> (Func<A, K<M, B>> f) Source #

where M : Monad<M>

Map each element of a structure to an action, evaluate these actions from left to right, and collect the results.

Parameters

type M

Monad trait

type B

Bound value (output)

param f
param ta

Traversable structure

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

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

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

method Fin<A> Bind (Func<A, Fail<Error>> f) Source #

method Fin<C> SelectMany <B, C> (Func<A, Fin<B>> bind, Func<A, B, C> project) Source #

method Fin<C> SelectMany <B, C> (Func<A, K<Fin, B>> bind, Func<A, B, C> project) Source #

method Fin<C> SelectMany <B, C> (Func<A, Pure<B>> bind, Func<A, B, C> project) Source #

method Fin<Unit> SelectMany (Func<A, Fail<Error>> bind, Func<A, Error, Unit> project) Source #

method Fin<Unit> SelectMany (Func<A, Guard<Error, Unit>> f) Source #

method Fin<C> SelectMany <C> (Func<A, Guard<Error, Unit>> bind, Func<A, Unit, C> project) Source #

method IEnumerable<A> AsEnumerable () Source #

method Iterable<A> ToIterable () Source #

method Lst<A> ToList () Source #

method Seq<A> ToSeq () Source #

method Arr<A> ToArray () Source #

method Option<A> ToOption () Source #

method Either<Error, A> ToEither () Source #

method Validation<Error, A> ToValidation () Source #

method Eff<A> ToEff () Source #

method A ThrowIfFail () Source #

Operators

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

Must exist here to make operator true work

operator true (Fin<A> ma) Source #

operator false (Fin<A> ma) Source #

operator == (Fin<A> ma, Fin<A> mb) Source #

operator != (Fin<A> ma, Fin<A> mb) Source #

operator < (Fin<A> lhs, A rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs〈 rhs

operator <= (Fin<A> lhs, A rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs〈= rhs

operator > (Fin<A> lhs, A rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs 〉rhs

operator >= (Fin<A> lhs, A rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs 〉= rhs

operator < (A lhs, Fin<A> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs〈 rhs

operator <= (A lhs, Fin<A> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs〈= rhs

operator > (A lhs, Fin<A>rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs 〉rhs

operator >= (A lhs, Fin<A> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs 〉= rhs

operator < (Fin<A> lhs, Fin<A> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs〈 rhs

operator <= (Fin<A> lhs, Fin<A> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs〈= rhs

operator > (Fin<A> lhs, Fin<A> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs > rhs

operator >= (Fin<A> lhs, Fin<A> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs >= rhs

operator == (Fin<A> lhs, Error rhs) Source #

Equality operator override

operator == (Fin<A> lhs, A rhs) Source #

Equality operator override

operator == (A lhs, Fin<A> rhs) Source #

Equality operator override

operator == (Error lhs, Fin<A> rhs) Source #

Equality operator override

operator != (Fin<A> lhs, Error rhs) Source #

Non-equality operator override

operator != (Error lhs, Fin<A> rhs) Source #

Non-equality operator override

operator != (Fin<A> lhs, A rhs) Source #

Equality operator override

operator != (A lhs, Fin<A> rhs) Source #

Equality operator override

class Fin <A> Source #

class Fail Source #

Fail case for the Fin union-type

Parameters

param Error

Error value

Properties

property Error Error Source #

Value accessor

property bool IsSucc Source #

Is the structure in a Success state?

property bool IsFail Source #

Is the structure in a Fail state?

Methods

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

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

Parameters

type B

Return type

param Succ

Function to invoke if in a Succ state

param Fail

Function to invoke if in a Fail state

returns

The return value of the invoked function

method string ToString () Source #

Show the structure as a string

method int GetHashCode <HashA> () Source #

method ReadOnlySpan<Error> FailSpan () Source #

Empty span

method ReadOnlySpan<A> SuccSpan () Source #

Span of right value

method int CompareTo <OrdA> (Fin<A> other) Source #

Compare this structure to another to find its relative ordering

method bool Equals <EqA> (Fin<A> other) Source #

Equality override

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

Maps the value in the structure

Parameters

param f

Map function

returns

Mapped structure

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

Maps the value in the structure

Parameters

param f

Map function

returns

Mapped structure

method Fin<B> BiMap <B> (Func<A, B> Succ, Func<Error, Error> Fail) Source #

Bi-maps the structure

Parameters

returns

Mapped Either

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

Monadic bind

Parameters

type B

Resulting bound value

param f

Bind function

returns

Bound structure

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

Bi-bind. Allows mapping of both monad states

method void Deconstruct (out Error value) Source #

class Fin Source #

Methods

method Fin<A> Succ <A> (A value) Source #

Construct a Fin value in a Succ state (success)

Parameters

type A

Value type

param value

Value to construct the Succ state with

returns

Constructed Fin value

method Fin<A> Fail <A> (Error error) Source #

Construct a Fin value in a Fail state

Parameters

type A

Value type

param value

Value to construct the Fail state with

returns

Constructed Fin value

method Fin<A> Fail <A> (string error) Source #

Construct a Fin value in a Fail state

Parameters

type A

Value type

param value

Value to construct the Fail state with

returns

Constructed Fin value

class Fin <A> Source #

class Succ Source #

Success case for the Fin union-type

Parameters

param Value

Success value

Properties

property A Value Source #

Value accessor

property bool IsSucc Source #

Is the structure in a Success state?

property bool IsFail Source #

Is the structure in a Fail state?

Methods

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

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

Parameters

type B

Return type

param Succ

Function to invoke if in a Succ state

param Fail

Function to invoke if in a Fail state

returns

The return value of the invoked function

method string ToString () Source #

Show the structure as a string

method int GetHashCode <HashA> () Source #

Get a hash code for the structure

method ReadOnlySpan<Error> FailSpan () Source #

Empty span

method ReadOnlySpan<A> SuccSpan () Source #

Span of right value

method int CompareTo <OrdA> (Fin<A>? other) Source #

Compare this structure to another to find its relative ordering

method bool Equals <EqA> (Fin<A> other) Source #

Equality override

method Fin<B> Map <B> (Func<A, B> Succ) Source #

Maps the value in the structure

Parameters

param f

Map function

returns

Mapped structure

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

Maps the value in the structure

Parameters

param f

Map function

returns

Mapped structure

method Fin<B> BiMap <B> (Func<A, B> Succ, Func<Error, Error> Fail) Source #

Bi-maps the structure

Parameters

returns

Mapped Either

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

Monadic bind

Parameters

type B

Resulting bound value

param f

Bind function

returns

Bound structure

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

Bi-bind. Allows mapping of both monad states

method void Deconstruct (out A value) Source #