LanguageExt.Core

LanguageExt.Core Monads Alternative Value Monads Either EitherAsync

Contents

struct EitherAsync <L, R> Source #

EitherAsync L R Holds one of two values 'Left' or 'Right'. Usually 'Left' is considered 'wrong' or 'in error', and 'Right' is, well, right. So when the Either is in a Left state, it cancels computations like bind or map, etc. So you can see Left as an 'early out, with a message'. Unlike Option that has None as its alternative value (i.e. it has an 'early out, but no message').

NOTE: If you use Filter or Where (or 'where' in a LINQ expression) with Either, then the Either will be put into a 'Bottom' state if the predicate returns false. When it's in this state it is neither Right nor Left. And any usage could trigger a BottomException. So be aware of the issue of filtering Either.

Also note, when the Either is in a Bottom state, some operations on it will continue to give valid results or return another Either in the Bottom state and not throw. This is so a filtered Either doesn't needlessly break expressions.

Parameters

type L

Left

type R

Right

Fields

field EitherAsync<L, R> Bottom = new EitherAsync<L, R>() Source #

Properties

property Task<EitherStatus> State Source #

State of the Either You can also use: IsRight IsLeft IsBottom

property Task<bool> IsRight Source #

Is the Either in a Right state?

property Task<bool> IsLeft Source #

Is the Either in a Left state?

property Task<bool> IsBottom Source #

Is the Either in a Bottom state? When the Either is filtered, both Right and Left are meaningless.

If you use Filter or Where (or 'where' in a LINQ expression) with Either, then the Either will be put into a 'Bottom' state if the predicate returns false. When it's in this state it is neither Right nor Left. And any usage could trigger a BottomException. So be aware of the issue of filtering Either.

Also note, when the Either is in a Bottom state, some operations on it will continue to give valid results or return another Either in the Bottom state and not throw. This is so a filtered Either doesn't needlessly break expressions.

property ValueTask<object> Case Source #

Reference version for use in pattern-matching

Methods

method TaskAwaiter<Either<L, R>> GetAwaiter () Source #

Custom awaiter that turns an EitherAsync into an Either

method bool Equals (object _) Source #

Equality operator

method Task<bool> Equals <EqL, EqR> (EitherAsync<L, R> rhs) Source #

where EqL : struct, EqAsync<L>
where EqR : struct, EqAsync<R>

Equality operator

method Task<bool> Equals (EitherAsync<L, R> rhs) Source #

Equality operator

method Task<int> CompareTo <OrdL, OrdR> (EitherAsync<L, R> rhs) Source #

where OrdL : struct, Ord<L>
where OrdR : struct, Ord<R>

Ordering

method Task<int> CompareTo (EitherAsync<L, R> rhs) Source #

Ordering

method Task<Ret> Match <Ret> (Func<R, Ret> Right, Func<L, Ret> Left, Func<Ret> Bottom = null) Source #

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

Parameters

type Ret

Return type

param Right

Function to invoke if in a Right state

param Left

Function to invoke if in a Left state

returns

The return value of the invoked function

method Task<Ret> MatchAsync <Ret> (Func<R, Ret> Right, Func<L, Task<Ret>> LeftAsync, Func<Ret> Bottom = null) Source #

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

Parameters

type Ret

Return type

param Right

Function to invoke if in a Right state

param LeftAsync

Function to invoke if in a Left state

returns

The return value of the invoked function

method Task<Ret> MatchAsync <Ret> (Func<R, Task<Ret>> RightAsync, Func<L, Ret> Left, Func<Ret> Bottom = null) Source #

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

Parameters

type Ret

Return type

param RightAsync

Function to invoke if in a Right state

param Left

Function to invoke if in a Left state

returns

The return value of the invoked function

method Task<Ret> MatchAsync <Ret> (Func<R, Task<Ret>> RightAsync, Func<L, Task<Ret>> LeftAsync, Func<Ret> Bottom = null) Source #

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

Parameters

type Ret

Return type

param RightAsync

Function to invoke if in a Right state

param LeftAsync

Function to invoke if in a Left state

returns

The return value of the invoked function

method Task<Ret> MatchUnsafe <Ret> (Func<R, Ret> Right, Func<L, Ret> Left, Func<Ret> Bottom = null) Source #

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

Parameters

type Ret

Return type

param Right

Function to invoke if in a Right state

param Left

Function to invoke if in a Left state

returns

The return value of the invoked function

method Task<Ret> MatchUnsafeAsync <Ret> (Func<R, Task<Ret>> RightAsync, Func<L, Ret> Left, Func<Ret> Bottom = null) Source #

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

Parameters

type Ret

Return type

param RightAsync

Function to invoke if in a Right state

param Left

Function to invoke if in a Left state

returns

The return value of the invoked function

method Task<Ret> MatchUnsafeAsync <Ret> (Func<R, Task<Ret>> RightAsync, Func<L, Task<Ret>> LeftAsync, Func<Ret> Bottom = null) Source #

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

Parameters

type Ret

Return type

param RightAsync

Function to invoke if in a Right state

param LeftAsync

Function to invoke if in a Left state

returns

The return value of the invoked function

method Task<Ret> MatchUnsafeAsync <Ret> (Func<R, Ret> Right, Func<L, Task<Ret>> LeftAsync, Func<Ret> Bottom = null) Source #

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

Parameters

type Ret

Return type

param Right

Function to invoke if in a Right state

param LeftAsync

Function to invoke if in a Left state

returns

The return value of the invoked function

method Task<Unit> Match (Action<R> Right, Action<L> Left, Action Bottom = null) 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 Task<Unit> MatchAsync (Action<R> Right, Func<L, Task> LeftAsync, Action Bottom = null) 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 LeftAsync

Action to invoke if in a Left state

returns

Unit

method Task<Unit> MatchAsync (Func<R, Task> RightAsync, Action<L> Left, Action Bottom = null) Source #

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

Parameters

param RightAsync

Action to invoke if in a Right state

param Left

Action to invoke if in a Left state

returns

Unit

method Task<Unit> MatchAsync (Func<R, Task> RightAsync, Func<L, Task> LeftAsync, Action Bottom = null) Source #

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

Parameters

param RightAsync

Action to invoke if in a Right state

param LeftAsync

Action to invoke if in a Left state

returns

Unit

method Task<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 Task<R> IfLeftAsync (Func<Task<R>> LeftAsync) 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 LeftAsync

Function to generate a Right value if in the Left state

returns

Returns an unwrapped Right value

method Task<R> IfLeft (Func<L, R> Left) 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 Left

Function to generate a Right value if in the Left state

returns

Returns an unwrapped Right value

method Task<R> IfLeftAsync (Func<L, Task<R>> LeftAsync) 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 LeftAsync

Function to generate a Right value if in the Left state

returns

Returns an unwrapped Right value

method Task<R> IfLeft (R Right) 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 Right

Value to return if in the Left state

returns

Returns an unwrapped Right value

method Task<R> IfLeftAsync (Task<R> RightAsync) 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 RightAsync

Value to return if in the Left state

returns

Returns an unwrapped Right value

method Task<Unit> IfLeft (Action<L> Left) Source #

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

Parameters

param Left

Action to invoke if in the Left state

returns

Returns an unwrapped Right value

method Task<Unit> IfLeftAsync (Func<L, Task> LeftAsync) Source #

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

Parameters

param LeftAsync

async Action to invoke if in the Left state

returns

Returns an unwrapped Right value

method Task<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 if in the Right state

returns

Unit

method Task<Unit> IfRightAsync (Func<R, Task> RightAsync) Source #

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

Parameters

param RightAsync

async Action to invoke if in the Right state

returns

Unit

method Task<L> IfRight (L Left) 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 Left

Value to return if in the Left state

returns

Returns an unwrapped Left value

method Task<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 Task<L> IfRightAsync (Func<Task<L>> RightAsync) 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 RightAsync

Function to generate a Left value if in the Right state

returns

Returns an unwrapped Left value

method Task<L> IfRight (Func<R, L> Right) 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 Right

Function to generate a Left value if in the Right state

returns

Returns an unwrapped Left value

method Task<L> IfRightAsync (Func<R, Task<L>> RightAsync) 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 RightAsync

Function to generate a Left value if in the Right state

returns

Returns an unwrapped Left value

method EitherAsyncUnitContext<L, R> Right (Action<R> right) Source #

Match Right and return a context. You must follow this with .Left(...) to complete the match

Parameters

param right

Action to invoke if the Either is in a Right state

returns

Context that must have Left() called upon it.

method EitherAsyncContext<L, R, Ret> Right <Ret> (Func<R, Ret> right) Source #

Match Right and return a context. You must follow this with .Left(...) to complete the match

Parameters

param right

Action to invoke if the Either is in a Right state

returns

Context that must have Left() called upon it.

method string ToString () Source #

Return a string representation of the Either

Parameters

returns

String representation of the Either

method Task<string> ToStringAsync () Source #

Return a string representation of the Either

Parameters

returns

String representation of the Either

method int GetHashCode () Source #

Returns a hash code of the wrapped value of the Either

Parameters

returns

Hash code

method Task<int> GetHashCodeAsync () Source #

Returns a hash code of the wrapped value of the Either

Parameters

returns

Hash code

method Task<Lst<R>> RightToList () Source #

Project the Either into a Lst R

Parameters

returns

If the Either is in a Right state, a Lst of R with one item. A zero length Lst R otherwise

method Task<Arr<R>> RightToArray () Source #

Project the Either into an ImmutableArray R

Parameters

returns

If the Either is in a Right state, a ImmutableArray of R with one item. A zero length ImmutableArray of R otherwise

method Task<Lst<L>> LeftToList () Source #

Project the Either into a Lst R

Parameters

returns

If the Either is in a Right state, a Lst of R with one item. A zero length Lst R otherwise

method Task<Arr<L>> LeftToArray () Source #

Project the Either into an ImmutableArray R

Parameters

returns

If the Either is in a Right state, a ImmutableArray of R with one item. A zero length ImmutableArray of R otherwise

method Task<Seq<R>> ToSeq () Source #

Convert either to sequence of 0 or 1 right values

method Task<Seq<R>> RightToSeq () Source #

Convert either to sequence of 0 or 1 right values

method Task<Seq<L>> LeftToSeq () Source #

Convert either to sequence of 0 or 1 left values

method Task<Seq<R>> RightAsEnumerable () Source #

Project the Either into a IEnumerable R

Parameters

returns

If the Either is in a Right state, a IEnumerable of R with one item. A zero length IEnumerable R otherwise

method Task<Seq<L>> LeftAsEnumerable () Source #

Project the Either into a IEnumerable L

Parameters

returns

If the Either is in a Left state, a IEnumerable of L with one item. A zero length IEnumerable L otherwise

method Task<Validation<L, R>> ToValidation () Source #

method OptionAsync<R> ToOption () Source #

Convert the Either to an Option

Parameters

returns

Some(Right) or None

method Aff<R> ToAff (Func<L, Common.Error> Left) Source #

Convert to an Aff

Parameters

param Left

Map the left value to the Eff Error

returns

Aff monad

method Task<EitherUnsafe<L, R>> ToEitherUnsafe () Source #

Convert the Either to an EitherUnsafe

Parameters

returns

EitherUnsafe

method Task<Either<L, R>> ToEither () Source #

Convert the EitherAsync to an Either

Parameters

returns

Either

method TryOptionAsync<R> ToTryOption () Source #

Convert the Either to an TryOption

Parameters

returns

Some(Right) or None

method Type GetUnderlyingRightType () Source #

Find out the underlying Right type

method Type GetUnderlyingLeftType () Source #

Find out the underlying Left type

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

method EitherAsync<L, R> RightAsync (Task<R> value) Source #

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

method EitherAsync<L, R> LeftAsync (Task<L> value) Source #

method Type GetUnderlyingType () Source #

method Task<int> Count () Source #

Counts the Either

Parameters

type L

Left

type R

Right

param self

Either to count

returns

1 if the Either is in a Right state, 0 otherwise.

method EitherAsync<R, L> Swap () Source #

Flips the left and right tagged values

Parameters

returns

Either with the types swapped

method Task<Unit> Iter (Action<R> Right) Source #

Iterate the Either action is invoked if in the Right state

method Task<Unit> BiIter (Action<R> Right, Action<L> Left) Source #

Iterate the Either action is invoked if in the Right state

method Task<bool> ForAll (Func<R, bool> Right) Source #

Invokes a predicate on the value of the Either if it's in the Right state

Parameters

type L

Left

type R

Right

param self

Either to forall

param Right

Predicate

returns

True if the Either is in a Left state. True if the Either is in a Right state and the predicate returns True. False otherwise.

method Task<bool> ForAllAsync (Func<R, Task<bool>> Right) Source #

Invokes a predicate on the value of the Either if it's in the Right state

Parameters

type L

Left

type R

Right

param self

Either to forall

param Right

Predicate

returns

True if the Either is in a Left state. True if the Either is in a Right state and the predicate returns True. False otherwise.

method Task<bool> BiForAll (Func<R, bool> Right, Func<L, bool> Left) Source #

Invokes a predicate on the value of the Either if it's in the Right state

Parameters

type L

Left

type R

Right

param self

Either to forall

param Right

Predicate

param Left

Predicate

returns

True if either Predicate returns true

method Task<bool> BiForAllAsync (Func<R, Task<bool>> RightAsync, Func<L, bool> Left) Source #

Invokes a predicate on the value of the Either if it's in the Right state

Parameters

type L

Left

type R

Right

param self

Either to forall

param RightAsync

Predicate

param Left

Predicate

returns

True if either Predicate returns true

method Task<bool> BiForAllAsync (Func<R, bool> Right, Func<L, Task<bool>> LeftAsync) Source #

Invokes a predicate on the value of the Either if it's in the Right state

Parameters

type L

Left

type R

Right

param self

Either to forall

param Right

Predicate

param LeftAsync

Predicate

returns

True if either Predicate returns true

method Task<bool> BiForAllAsync (Func<R, Task<bool>> RightAsync, Func<L, Task<bool>> LeftAsync) Source #

Invokes a predicate on the value of the Either if it's in the Right state

Parameters

type L

Left

type R

Right

param self

Either to forall

param RightAsync

Predicate

param LeftAsync

Predicate

returns

True if either Predicate returns true

method Task<S> Fold <S> (S state, Func<S, R, S> Right) Source #

Either types are like lists of 0 or 1 items, and therefore follow the same rules when folding.

In the case of lists, 'Fold', when applied to a binary operator, a starting value(typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:

Parameters

type S

Aggregate state type

param state

Initial state

param Right

Folder function, applied if structure is in a Right state

returns

The aggregate state

method Task<S> FoldAsync <S> (S state, Func<S, R, Task<S>> RightAsync) Source #

Either types are like lists of 0 or 1 items, and therefore follow the same rules when folding.

In the case of lists, 'Fold', when applied to a binary operator, a starting value(typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:

Parameters

type S

Aggregate state type

param state

Initial state

param RightAsync

Folder function, applied if structure is in a Right state

returns

The aggregate state

method Task<S> BiFold <S> (S state, Func<S, R, S> Right, Func<S, L, S> Left) Source #

Either types are like lists of 0 or 1 items, and therefore follow the same rules when folding.

In the case of lists, 'Fold', when applied to a binary operator, a starting value(typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:

Parameters

type S

Aggregate state type

param state

Initial state

param Right

Folder function, applied if Either is in a Right state

param Left

Folder function, applied if Either is in a Left state

returns

The aggregate state

method Task<S> BiFoldAsync <S> (S state, Func<S, R, Task<S>> RightAsync, Func<S, L, S> Left) Source #

Either types are like lists of 0 or 1 items, and therefore follow the same rules when folding.

In the case of lists, 'Fold', when applied to a binary operator, a starting value(typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:

Parameters

type S

Aggregate state type

param state

Initial state

param RightAsync

Folder function, applied if Either is in a Right state

param Left

Folder function, applied if Either is in a Left state

returns

The aggregate state

method Task<S> BiFoldAsync <S> (S state, Func<S, R, Task<S>> RightAsync, Func<S, L, Task<S>> LeftAsync) Source #

Either types are like lists of 0 or 1 items, and therefore follow the same rules when folding.

In the case of lists, 'Fold', when applied to a binary operator, a starting value(typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:

Parameters

type S

Aggregate state type

param state

Initial state

param RightAsync

Folder function, applied if Either is in a Right state

param LeftAsync

Folder function, applied if Either is in a Left state

returns

The aggregate state

method Task<S> BiFoldAsync <S> (S state, Func<S, R, S> Right, Func<S, L, Task<S>> LeftAsync) Source #

Either types are like lists of 0 or 1 items, and therefore follow the same rules when folding.

In the case of lists, 'Fold', when applied to a binary operator, a starting value(typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:

Parameters

type S

Aggregate state type

param state

Initial state

param Right

Folder function, applied if Either is in a Right state

param LeftAsync

Folder function, applied if Either is in a Left state

returns

The aggregate state

method Task<bool> Exists (Func<R, bool> pred) Source #

Invokes a predicate on the value of the Either if it's in the Right state

Parameters

type L

Left

type R

Right

param self

Either to check existence of

param pred

Predicate

returns

True if the Either is in a Right state and the predicate returns True. False otherwise.

method Task<bool> ExistsAsync (Func<R, Task<bool>> pred) Source #

Invokes a predicate on the value of the Either if it's in the Right state

Parameters

type L

Left

type R

Right

param self

Either to check existence of

param pred

Predicate

returns

True if the Either is in a Right state and the predicate returns True. False otherwise.

method Task<bool> BiExists (Func<R, bool> Right, Func<L, bool> Left) Source #

Invokes a predicate on the value of the Either

Parameters

type L

Left

type R

Right

param self

Either to check existence of

param Right

Right predicate

param Left

Left predicate

returns

True if the predicate returns True. False otherwise or if the Either is in a bottom state.

method Task<bool> BiExistsAsync (Func<R, Task<bool>> RightAsync, Func<L, bool> Left) Source #

Invokes a predicate on the value of the Either

Parameters

type L

Left

type R

Right

param self

Either to check existence of

param RightAsync

Right predicate

param Left

Left predicate

returns

True if the predicate returns True. False otherwise or if the Either is in a bottom state.

method Task<bool> BiExistsAsync (Func<R, Task<bool>> RightAsync, Func<L, Task<bool>> LeftAsync) Source #

Invokes a predicate on the value of the Either

Parameters

type L

Left

type R

Right

param self

Either to check existence of

param RightAsync

Right predicate

param LeftAsync

Left predicate

returns

True if the predicate returns True. False otherwise or if the Either is in a bottom state.

method Task<bool> BiExistsAsync (Func<R, bool> Right, Func<L, Task<bool>> LeftAsync) Source #

Invokes a predicate on the value of the Either

Parameters

type L

Left

type R

Right

param self

Either to check existence of

param Right

Right predicate

param LeftAsync

Left predicate

returns

True if the predicate returns True. False otherwise or if the Either is in a bottom state.

method EitherAsync<L, R> Do (Action<R> f) Source #

Impure iteration of the bound values in the structure

Parameters

returns

Returns the original unmodified structure

method EitherAsync<L, Ret> Map <Ret> (Func<R, Ret> f) Source #

Maps the value in the Either if it's in a Right state

Parameters

type L

Left

type R

Right

type Ret

Mapped Either type

param self

Either to map

param f

Map function

returns

Mapped Either

method EitherAsync<L, Ret> MapAsync <Ret> (Func<R, Task<Ret>> f) Source #

Maps the value in the Either if it's in a Right state

Parameters

type L

Left

type R

Right

type Ret

Mapped Either type

param self

Either to map

param mapper

Map function

returns

Mapped Either

method EitherAsync<Ret, R> MapLeft <Ret> (Func<L, Ret> f) Source #

Maps the value in the Either if it's in a Left state

Parameters

type L

Left

type R

Right

type Ret

Mapped Either type

param self

Either to map

param f

Map function

returns

Mapped Either

method EitherAsync<Ret, R> MapLeftAsync <Ret> (Func<L, Task<Ret>> f) Source #

Maps the value in the Either if it's in a Left state

Parameters

type L

Left

type R

Right

type Ret

Mapped Either type

param self

Either to map

param f

Map function

returns

Mapped Either

method EitherAsync<L, Ret> BiMapAsync <Ret> (Func<R, Task<Ret>> RightAsync, Func<L, Ret> Left) Source #

Bi-maps the value in the Either into a Right state

Parameters

type L

Left

type R

Right

type LRet

Left return

type RRet

Right return

param self

Either to map

param RightAsync

Right map function

param Left

Left map function

returns

Mapped Either

method EitherAsync<L, Ret> BiMapAsync <Ret> (Func<R, Ret> Right, Func<L, Task<Ret>> LeftAsync) Source #

Bi-maps the value in the Either into a Right state

Parameters

type L

Left

type R

Right

type LRet

Left return

type RRet

Right return

param self

Either to map

param Right

Right map function

param LeftAsync

Left map function

returns

Mapped Either

method EitherAsync<L2, R2> BiMap <L2, R2> (Func<R, R2> Right, Func<L, L2> Left) Source #

Bi-maps the value in the Either if it's in a Right state

Parameters

type L

Left

type R

Right

type LRet

Left return

type RRet

Right return

param self

Either to map

param Right

Right map function

param Left

Left map function

returns

Mapped Either

method EitherAsync<L2, R2> BiMapAsync <L2, R2> (Func<R, Task<R2>> RightAsync, Func<L, L2> Left) Source #

Bi-maps the value in the Either if it's in a Right state

Parameters

type L

Left

type R

Right

type LRet

Left return

type RRet

Right return

param self

Either to map

param RightAsync

Right map function

param Left

Left map function

returns

Mapped Either

method EitherAsync<L2, R2> BiMapAsync <L2, R2> (Func<R, R2> Right, Func<L, Task<L2>> LeftAsync) Source #

Bi-maps the value in the Either if it's in a Right state

Parameters

type L

Left

type R

Right

type LRet

Left return

type RRet

Right return

param self

Either to map

param Right

Right map function

param LeftAsync

Left map function

returns

Mapped Either

method EitherAsync<L2, R2> BiMapAsync <L2, R2> (Func<R, Task<R2>> RightAsync, Func<L, Task<L2>> LeftAsync) Source #

Bi-maps the value in the Either if it's in a Right state

Parameters

type L

Left

type R

Right

type LRet

Left return

type RRet

Right return

param self

Either to map

param RightAsync

Right map function

param LeftAsync

Left map function

returns

Mapped Either

method EitherAsync<L, Ret> Bind <Ret> (Func<R, EitherAsync<L, Ret>> f) Source #

Monadic bind

Parameters

type L

Left

type R

Right

type Ret
param self
param f
returns

Bound Either

method EitherAsync<L, Ret> BindAsync <Ret> (Func<R, Task<EitherAsync<L, Ret>>> f) Source #

Monadic bind

Parameters

type L

Left

type R

Right

type Ret
param self
param f
returns

Bound Either

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

Bi-bind. Allows mapping of both monad states

method EitherAsync<L, B> BiBindAsync <B> (Func<R, Task<EitherAsync<L, B>>> RightAsync, Func<L, EitherAsync<L, B>> Left) Source #

Bi-bind. Allows mapping of both monad states

method EitherAsync<L, B> BiBindAsync <B> (Func<R, EitherAsync<L, B>> Right, Func<L, Task<EitherAsync<L, B>>> LeftAsync) Source #

Bi-bind. Allows mapping of both monad states

method EitherAsync<L, B> BiBindAsync <B> (Func<R, Task<EitherAsync<L, B>>> RightAsync, Func<L, Task<EitherAsync<L, B>>> LeftAsync) Source #

Bi-bind. Allows mapping of both monad states

method EitherAsync<B, R> BindLeft <B> (Func<L, EitherAsync<B, R>> Left) Source #

Bind left. Binds the left path of the monad only

method EitherAsync<B, R> BindLeftAsync <B> (Func<L, Task<EitherAsync<B, R>>> LeftAsync) Source #

Bind left. Binds the left path of the monad only

method EitherAsync<L, R> Filter (Func<R, bool> pred) Source #

Filter the Either

This may give unpredictable results for a filtered value. The Either won't return true for IsLeft or IsRight. IsBottom is True if the value is filtered and that should be checked for.

Parameters

type L

Left

type R

Right

param self

Either to filter

param pred

Predicate function

returns

If the Either is in the Left state it is returned as-is. If in the Right state the predicate is applied to the Right value. If the predicate returns True the Either is returned as-is. If the predicate returns False the Either is returned in a 'Bottom' state.

method EitherAsync<L, R> FilterAsync (Func<R, Task<bool>> pred) Source #

Filter the Either

This may give unpredictable results for a filtered value. The Either won't return true for IsLeft or IsRight. IsBottom is True if the value is filtered and that should be checked for.

Parameters

type L

Left

type R

Right

param self

Either to filter

param pred

Predicate function

returns

If the Either is in the Left state it is returned as-is. If in the Right state the predicate is applied to the Right value. If the predicate returns True the Either is returned as-is. If the predicate returns False the Either is returned in a 'Bottom' state.

method EitherAsync<L, R> Where (Func<R, bool> pred) Source #

Filter the Either

This may give unpredictable results for a filtered value. The Either won't return true for IsLeft or IsRight. IsBottom is True if the value is filtered and that should be checked for.

Parameters

type L

Left

type R

Right

param self

Either to filter

param pred

Predicate function

returns

If the Either is in the Left state it is returned as-is. If in the Right state the predicate is applied to the Right value. If the predicate returns True the Either is returned as-is. If the predicate returns False the Either is returned in a 'Bottom' state. IsLeft will return True, but the value of Left = default(L)

method EitherAsync<L, U> Select <U> (Func<R, U> map) Source #

Maps the value in the Either if it's in a Right state

Parameters

type L

Left

type TR

Right

type UR

Mapped Either type

param self

Either to map

param map

Map function

returns

Mapped Either

method EitherAsync<L, V> SelectMany <U, V> (Func<R, EitherAsync<L, U>> bind, Func<R, U, V> project) Source #

Monadic bind function

Parameters

returns

Bound Either

method IAsyncEnumerator<R> GetAsyncEnumerator (CancellationToken cancellationToken = default) Source #

Enumerate asynchronously

Operators

operator == (EitherAsync<L, R> lhs, EitherAsync<L, R> rhs) Source #

Equality operator

operator != (EitherAsync<L, R> lhs, EitherAsync<L, R> rhs) Source #

Non-equality operator

operator < (EitherAsync<L, R> lhs, EitherAsync<L, R> rhs) Source #

Ordering operator

operator <= (EitherAsync<L, R> lhs, EitherAsync<L, R> rhs) Source #

Ordering operator

operator > (EitherAsync<L, R> lhs, EitherAsync<L, R> rhs) Source #

Ordering operator

operator >= (EitherAsync<L, R> lhs, EitherAsync<L, R> rhs) Source #

Ordering operator

operator | (EitherAsync<L, R> lhs, EitherAsync<L, R> rhs) Source #

Override of the Or operator to be a Left coalescing operator

struct EitherAsyncContext <L, R, Ret> Source #

Context for the fluent EitherAsync matching

Methods

method Task<Ret> Left (Func<L, Ret> left) Source #

Left match

Parameters

param left
returns

Result of the match

struct EitherAsyncUnitContext <L, R> Source #

Context for the fluent EitherAsync matching

Methods

method Task<Unit> Left (Action<L> leftHandler) Source #

class EitherAsyncExtensions Source #

Extension methods for Either

Methods

method EitherAsync<L, R> Flatten <L, R> (this EitherAsync<L, EitherAsync<L, R>> ma) Source #

Monadic join

method EitherAsync<L, R> Flatten <L, R> (this EitherAsync<EitherAsync<L, R>, EitherAsync<L, R>> ma) Source #

Monadic join

method EitherAsync<L, R> Plus <NUM, L, R> (this EitherAsync<L, R> x, EitherAsync<L, R> y) Source #

where NUM : struct, Num<R>

Add the bound values of x and y, uses an Add type-class to provide the add operation for type A. For example x.Add<TInteger,int>(y)

Parameters

type NUM

Num of A

type A

Bound value type

param x

Left hand side of the operation

param y

Right hand side of the operation

returns

An option with y added to x

method EitherAsync<L, R> Subtract <NUM, L, R> (this EitherAsync<L, R> x, EitherAsync<L, R> y) Source #

where NUM : struct, Num<R>

Find the subtract between the two bound values of x and y, uses a Subtract type-class to provide the subtract operation for type A. For example x.Subtract<TInteger,int>(y)

Parameters

type NUM

Num of A

type A

Bound value type

param x

Left hand side of the operation

param y

Right hand side of the operation

returns

An option with the subtract between x and y

method EitherAsync<L, R> Product <NUM, L, R> (this EitherAsync<L, R> x, EitherAsync<L, R> y) Source #

where NUM : struct, Num<R>

Find the product between the two bound values of x and y, uses a Product type-class to provide the product operation for type A. For example x.Product<TInteger,int>(y)

Parameters

type NUM

Num of A

type A

Bound value type

param x

Left hand side of the operation

param y

Right hand side of the operation

returns

An option with the product of x and y

method EitherAsync<L, R> Divide <NUM, L, R> (this EitherAsync<L, R> x, EitherAsync<L, R> y) Source #

where NUM : struct, Num<R>

Divide the two bound values of x and y, uses a Divide type-class to provide the divide operation for type A. For example x.Divide<TDouble,double>(y)

Parameters

type NUM

Num of A

type A

Bound value type

param x

Left hand side of the operation

param y

Right hand side of the operation

returns

An option x / y

method EitherAsync<L, B> Apply <L, A, B> (this EitherAsync<L, Func<A, B>> fab, EitherAsync<L, A> fa) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative to apply

returns

Applicative of type FB derived from Applicative of B

method EitherAsync<L, B> Apply <L, A, B> (this Func<A, B> fab, EitherAsync<L, A> fa) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative to apply

returns

Applicative of type FB derived from Applicative of B

method EitherAsync<L, C> Apply <L, A, B, C> (this EitherAsync<L, Func<A, B, C>> fabc, EitherAsync<L, A> fa, EitherAsync<L, B> fb) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative a to apply

param fb

Applicative b to apply

returns

Applicative of type FC derived from Applicative of C

method EitherAsync<L, C> Apply <L, A, B, C> (this Func<A, B, C> fabc, EitherAsync<L, A> fa, EitherAsync<L, B> fb) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative a to apply

param fb

Applicative b to apply

returns

Applicative of type FC derived from Applicative of C

method EitherAsync<L, Func<B, C>> Apply <L, A, B, C> (this EitherAsync<L, Func<A, B, C>> fabc, EitherAsync<L, A> fa) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative to apply

returns

Applicative of type f(b -> c) derived from Applicative of Func<B, C>

method EitherAsync<L, Func<B, C>> Apply <L, A, B, C> (this Func<A, B, C> fabc, EitherAsync<L, A> fa) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative to apply

returns

Applicative of type f(b -> c) derived from Applicative of Func<B, C>

method EitherAsync<L, Func<B, C>> Apply <L, A, B, C> (this EitherAsync<L, Func<A, Func<B, C>>> fabc, EitherAsync<L, A> fa) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative to apply

returns

Applicative of type f(b -> c) derived from Applicative of Func<B, C>

method EitherAsync<L, Func<B, C>> Apply <L, A, B, C> (this Func<A, Func<B, C>> fabc, EitherAsync<L, A> fa) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative to apply

returns

Applicative of type f(b -> c) derived from Applicative of Func<B, C>

method EitherAsync<L, B> Action <L, A, B> (this EitherAsync<L, A> fa, EitherAsync<L, B> fb) Source #

Evaluate fa, then fb, ignoring the result of fa

Parameters

param fa

Applicative to evaluate first

param fb

Applicative to evaluate second and then return

returns

Applicative of type Option

method Task<IEnumerable<L>> Lefts <L, R> (this IEnumerable<EitherAsync<L, R>> self) Source #

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 Task<Seq<L>> Lefts <L, R> (this Seq<EitherAsync<L, R>> self) Source #

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 Task<IEnumerable<R>> Rights <L, R> (this IEnumerable<EitherAsync<L, R>> self) Source #

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 Task<Seq<R>> Rights <L, R> (this Seq<EitherAsync<L, R>> self) Source #

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 Task<(Seq<L> Lefts, Seq<R> Rights)> Partition <L, R> (this Seq<EitherAsync<L, R>> self) Source #

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 an enumerable of L and an enumerable of R

method Task<(IEnumerable<L> Lefts, IEnumerable<R> Rights)> Partition <L, R> (this IEnumerable<EitherAsync<L, R>> self) Source #

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 an enumerable of L and an enumerable of R

method Task<R> Sum <NUM, L, R> (this EitherAsync<L, R> self) Source #

where NUM : struct, Num<R>

Sum of the Either

Parameters

type L

Left

param self

Either to count

returns

0 if Left, or value of Right

method Task<int> Sum <L> (this EitherAsync<L, int> self) Source #

Sum of the Either

Parameters

type L

Left

param self

Either to count

returns

0 if Left, or value of Right

method EitherAsync<L, Func<T2, R>> ParMap <L, T1, T2, R> (this EitherAsync<L, T1> self, Func<T1, T2, R> func) Source #

Partial application map

method EitherAsync<L, Func<T2, Func<T3, R>>> ParMap <L, T1, T2, T3, R> (this EitherAsync<L, T1> self, Func<T1, T2, T3, R> func) Source #

Partial application map

method Aff<R> ToAff <R> (EitherAsync<Error, R> ma) Source #

Convert to an Aff

Parameters

returns

Aff monad

method Aff<R> ToAff <R> (EitherAsync<Exception, R> ma) Source #

Convert to an Aff

Parameters

returns

Aff monad

method Aff<R> ToAff <R> (EitherAsync<string, R> ma) Source #

Convert to an Aff

Parameters

returns

Aff monad

class EitherAsyncGuardExtensions Source #

Methods

method EitherAsync<L, Unit> ToEitherAsync <L> (this Guard<L> ma) Source #

method EitherAsync<L, B> SelectMany <L, B> (this Guard<L> ma, Func<Unit, EitherAsync<L, B>> f) Source #

method EitherAsync<L, C> SelectMany <L, B, C> (this Guard<L> ma, Func<Unit, EitherAsync<L, B>> bind, Func<Unit, B, C> project) Source #

method EitherAsync<L, Unit> SelectMany <L, A> (this EitherAsync<L, A> ma, Func<A, Guard<L>> f) Source #

method EitherAsync<L, C> SelectMany <L, A, C> (this EitherAsync<L, A> ma, Func<A, Guard<L>> bind, Func<A, Unit, C> project) Source #

class Prelude Source #

Methods

method EitherAsync<L, R> flatten <L, R> (EitherAsync<L, EitherAsync<L, R>> ma) Source #

Monadic join

method EitherAsync<L, R> plus <NUM, L, R> (EitherAsync<L, R> x, EitherAsync<L, R> y) Source #

where NUM : struct, Num<R>

Add the bound values of x and y, uses an Add type-class to provide the add operation for type A. For example x.Add<TInteger,int>(y)

Parameters

type NUM

Num of A

type A

Bound value type

param x

Left hand side of the operation

param y

Right hand side of the operation

returns

An option with y added to x

method EitherAsync<L, R> subtract <NUM, L, R> (EitherAsync<L, R> x, EitherAsync<L, R> y) Source #

where NUM : struct, Num<R>

Find the subtract between the two bound values of x and y, uses a Subtract type-class to provide the subtract operation for type A. For example x.Subtract<TInteger,int>(y)

Parameters

type NUM

Num of A

type A

Bound value type

param x

Left hand side of the operation

param y

Right hand side of the operation

returns

An option with the subtract between x and y

method EitherAsync<L, R> product <NUM, L, R> (EitherAsync<L, R> x, EitherAsync<L, R> y) Source #

where NUM : struct, Num<R>

Find the product between the two bound values of x and y, uses a Product type-class to provide the product operation for type A. For example x.Product<TInteger,int>(y)

Parameters

type NUM

Num of A

type A

Bound value type

param x

Left hand side of the operation

param y

Right hand side of the operation

returns

An option with the product of x and y

method EitherAsync<L, R> divide <NUM, L, R> (EitherAsync<L, R> x, EitherAsync<L, R> y) Source #

where NUM : struct, Num<R>

Divide the two bound values of x and y, uses a Divide type-class to provide the divide operation for type A. For example x.Divide<TDouble,double>(y)

Parameters

type NUM

Num of A

type A

Bound value type

param x

Left hand side of the operation

param y

Right hand side of the operation

returns

An option x / y

method EitherAsync<L, B> apply <L, A, B> (EitherAsync<L, Func<A, B>> fab, EitherAsync<L, A> fa) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative to apply

returns

Applicative of type FB derived from Applicative of B

method EitherAsync<L, B> apply <L, A, B> (Func<A, B> fab, EitherAsync<L, A> fa) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative to apply

returns

Applicative of type FB derived from Applicative of B

method EitherAsync<L, C> apply <L, A, B, C> (EitherAsync<L, Func<A, B, C>> fabc, EitherAsync<L, A> fa, EitherAsync<L, B> fb) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative a to apply

param fb

Applicative b to apply

returns

Applicative of type FC derived from Applicative of C

method EitherAsync<L, C> apply <L, A, B, C> (Func<A, B, C> fabc, EitherAsync<L, A> fa, EitherAsync<L, B> fb) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative a to apply

param fb

Applicative b to apply

returns

Applicative of type FC derived from Applicative of C

method EitherAsync<L, Func<B, C>> apply <L, A, B, C> (EitherAsync<L, Func<A, B, C>> fabc, EitherAsync<L, A> fa) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative to apply

returns

Applicative of type f(b -> c) derived from Applicative of Func<B, C>

method EitherAsync<L, Func<B, C>> apply <L, A, B, C> (Func<A, B, C> fabc, EitherAsync<L, A> fa) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative to apply

returns

Applicative of type f(b -> c) derived from Applicative of Func<B, C>

method EitherAsync<L, Func<B, C>> apply <L, A, B, C> (EitherAsync<L, Func<A, Func<B, C>>> fabc, EitherAsync<L, A> fa) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative to apply

returns

Applicative of type f(b -> c) derived from Applicative of Func<B, C>

method EitherAsync<L, Func<B, C>> apply <L, A, B, C> (Func<A, Func<B, C>> fabc, EitherAsync<L, A> fa) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative to apply

returns

Applicative of type f(b -> c) derived from Applicative of Func<B, C>

method EitherAsync<L, B> action <L, A, B> (EitherAsync<L, A> fa, EitherAsync<L, B> fb) Source #

Evaluate fa, then fb, ignoring the result of fa

Parameters

param fa

Applicative to evaluate first

param fb

Applicative to evaluate second and then return

returns

Applicative of type Option

method Task<bool> isRight <L, R> (EitherAsync<L, R> value) Source #

Returns the state of the Either provided

Parameters

type L

Left

type R

Right

param value

Either to check

returns

True if the Either is in a Right state

method Task<bool> isLeft <L, R> (EitherAsync<L, R> value) Source #

Returns the state of the Either provided

Parameters

type L

Left

type R

Right

param value

Either to check

returns

True if the Either is in a Left state

method EitherAsync<L, R> RightAsync <L, R> (Task<R> value) Source #

Either constructor Constructs an Either in a Right state

Parameters

type L

Left

type R

Right

param value

Right value

returns

A new Either instance

method EitherAsync<L, R> RightAsync <L, R> (Func<Unit, Task<R>> value) Source #

Either constructor Constructs an Either in a Right state

Parameters

type L

Left

type R

Right

param value

Right value

returns

A new Either instance

method EitherAsync<L, R> RightAsync <L, R> (R value) Source #

Either constructor Constructs an Either in a Right state

Parameters

type L

Left

type R

Right

param value

Right value

returns

A new Either instance

method EitherAsync<L, R> LeftAsync <L, R> (Task<L> value) Source #

Either constructor Constructs an Either in a Left state

Parameters

type L

Left

type R

Right

param value

Left value

returns

A new Either instance

method EitherAsync<L, R> LeftAsync <L, R> (Func<Unit, Task<L>> value) Source #

Either constructor Constructs an Either in a Left state

Parameters

type L

Left

type R

Right

param value

Left value

returns

A new Either instance

method EitherAsync<L, R> LeftAsync <L, R> (L value) Source #

Either constructor Constructs an Either in a Left state

Parameters

type L

Left

type R

Right

param value

Left value

returns

A new Either instance

method Task<R> ifLeft <L, R> (EitherAsync<L, R> either, Func<R> LeftSync) 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 Task<R> ifLeft <L, R> (EitherAsync<L, R> either, Func<L, R> LeftSync) 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 Task<R> ifLeftAsync <L, R> (EitherAsync<L, R> either, Func<L, Task<R>> LeftAsync) 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 Task<R> ifLeft <L, R> (EitherAsync<L, R> either, R Right) 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 Task<Unit> ifLeft <L, R> (EitherAsync<L, R> either, 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 Task<Unit> ifLeftAsync <L, R> (EitherAsync<L, R> either, Func<L, Task> 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 Task<Unit> ifRight <L, R> (EitherAsync<L, R> either, 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 Task<Unit> ifRightAsync <L, R> (EitherAsync<L, R> either, Func<R, Task> RightAsync) 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 Task<L> ifRight <L, R> (EitherAsync<L, R> either, L Left) Source #

Returns the Left argument if the Either is in a Right state. Returns the Left value from the Either if it's in a Left state.

Parameters

param Left

Value to return if in the Left state

returns

Returns an unwrapped Left value

method Task<L> ifRightAsync <L, R> (EitherAsync<L, R> either, Func<Task<L>> RightAsync) Source #

Returns the Left argument if the Either is in a Right state. Returns the Left value from the Either if it's in a Left state.

Parameters

param Left

Value to return if in the Left state

returns

Returns an unwrapped Left value

method Task<L> ifRight <L, R> (EitherAsync<L, R> either, Func<L> Left) Source #

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

Parameters

param Left

Function to generate a Left value if in the Right state

returns

Returns an unwrapped Left value

method Task<L> ifRight <L, R> (EitherAsync<L, R> either, Func<R, L> Left) Source #

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

Parameters

param Left

Function to generate a Left value if in the Right state

returns

Returns an unwrapped Left value

method Task<L> ifRightAsync <L, R> (EitherAsync<L, R> either, Func<R, Task<L>> LeftAsync) Source #

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

Parameters

param Left

Function to generate a Left value if in the Right state

returns

Returns an unwrapped Left value

method Task<Ret> match <L, R, Ret> (EitherAsync<L, R> either, Func<R, Ret> Right, Func<L, Ret> Left, Func<Ret> Bottom = null) Source #

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

Parameters

type L

Left

type R

Right

type Ret

Return type

param either

Either to match

param Right

Function to invoke if in a Right state

param Left

Function to invoke if in a Left state

returns

The return value of the invoked function

method Task<Ret> matchAsync <L, R, Ret> (EitherAsync<L, R> either, Func<R, Task<Ret>> RightAsync, Func<L, Ret> Left, Func<Ret> Bottom = null) Source #

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

Parameters

type L

Left

type R

Right

type Ret

Return type

param either

Either to match

param Right

Function to invoke if in a Right state

param Left

Function to invoke if in a Left state

returns

The return value of the invoked function

method Task<Ret> matchAsync <L, R, Ret> (EitherAsync<L, R> either, Func<R, Ret> Right, Func<L, Task<Ret>> LeftAsync, Func<Ret> Bottom = null) Source #

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

Parameters

type L

Left

type R

Right

type Ret

Return type

param either

Either to match

param Right

Function to invoke if in a Right state

param Left

Function to invoke if in a Left state

returns

The return value of the invoked function

method Task<Ret> matchAsync <L, R, Ret> (EitherAsync<L, R> either, Func<R, Task<Ret>> RightAsync, Func<L, Task<Ret>> LeftAsync, Func<Ret> Bottom = null) Source #

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

Parameters

type L

Left

type R

Right

type Ret

Return type

param either

Either to match

param Right

Function to invoke if in a Right state

param Left

Function to invoke if in a Left state

returns

The return value of the invoked function

method Task<Unit> match <L, R> (EitherAsync<L, R> either, Action<R> Right, Action<L> Left, Action Bottom = null) Source #

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

Parameters

type L

Left

type R

Right

param either

Either to match

param Right

Action to invoke if in a Right state

param Left

Action to invoke if in a Left state

returns

Unit

method Task<Unit> matchAsync <L, R> (EitherAsync<L, R> either, Func<R, Task> RightAsync, Action<L> Left, Action Bottom = null) Source #

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

Parameters

type L

Left

type R

Right

param either

Either to match

param Right

Action to invoke if in a Right state

param Left

Action to invoke if in a Left state

returns

Unit

method Task<Unit> matchAsync <L, R> (EitherAsync<L, R> either, Action<R> Right, Func<L, Task> LeftAsync, Action Bottom = null) Source #

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

Parameters

type L

Left

type R

Right

param either

Either to match

param Right

Action to invoke if in a Right state

param Left

Action to invoke if in a Left state

returns

Unit

method Task<Unit> matchAsync <L, R> (EitherAsync<L, R> either, Func<R, Task> RightAsync, Func<L, Task> LeftAsync, Action Bottom = null) Source #

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

Parameters

type L

Left

type R

Right

param either

Either to match

param Right

Action to invoke if in a Right state

param Left

Action to invoke if in a Left state

returns

Unit

method Task<S> fold <S, L, R> (EitherAsync<L, R> either, S state, Func<S, R, S> Right) Source #

Either types are like lists of 0 or 1 items, and therefore follow the same rules when folding.

In the case of lists, 'Fold', when applied to a binary operator, a starting value(typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:

Parameters

type S

Aggregate state type

param state

Initial state

param Right

Folder function, applied if structure is in a Right state

returns

The aggregate state

method Task<S> foldAsync <S, L, R> (EitherAsync<L, R> either, S state, Func<S, R, Task<S>> RightAsync) Source #

Either types are like lists of 0 or 1 items, and therefore follow the same rules when folding.

In the case of lists, 'Fold', when applied to a binary operator, a starting value(typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:

Parameters

type S

Aggregate state type

param state

Initial state

param RightAsync

Folder function, applied if structure is in a Right state

returns

The aggregate state

method Task<S> bifold <L, R, S> (EitherAsync<L, R> either, S state, Func<S, R, S> Right, Func<S, L, S> Left) Source #

Either types are like lists of 0 or 1 items, and therefore follow the same rules when folding.

In the case of lists, 'Fold', when applied to a binary operator, a starting value(typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:

Parameters

type S

Aggregate state type

param state

Initial state

param Right

Folder function, applied if Either is in a Right state

param Left

Folder function, applied if Either is in a Left state

returns

The aggregate state

method Task<S> bifoldAsync <L, R, S> (EitherAsync<L, R> either, S state, Func<S, R, Task<S>> RightAsync, Func<S, L, S> Left) Source #

Either types are like lists of 0 or 1 items, and therefore follow the same rules when folding.

In the case of lists, 'Fold', when applied to a binary operator, a starting value(typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:

Parameters

type S

Aggregate state type

param state

Initial state

param Right

Folder function, applied if Either is in a Right state

param Left

Folder function, applied if Either is in a Left state

returns

The aggregate state

method Task<S> bifoldAsync <L, R, S> (EitherAsync<L, R> either, S state, Func<S, R, S> Right, Func<S, L, Task<S>> LeftAsync) Source #

Either types are like lists of 0 or 1 items, and therefore follow the same rules when folding.

In the case of lists, 'Fold', when applied to a binary operator, a starting value(typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:

Parameters

type S

Aggregate state type

param state

Initial state

param Right

Folder function, applied if Either is in a Right state

param Left

Folder function, applied if Either is in a Left state

returns

The aggregate state

method Task<S> bifoldAsync <L, R, S> (EitherAsync<L, R> either, S state, Func<S, R, Task<S>> RightAsync, Func<S, L, Task<S>> LeftAsync) Source #

Either types are like lists of 0 or 1 items, and therefore follow the same rules when folding.

In the case of lists, 'Fold', when applied to a binary operator, a starting value(typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:

Parameters

type S

Aggregate state type

param state

Initial state

param Right

Folder function, applied if Either is in a Right state

param Left

Folder function, applied if Either is in a Left state

returns

The aggregate state

method Task<bool> forall <L, R> (EitherAsync<L, R> either, Func<R, bool> pred) Source #

Invokes a predicate on the value of the Either if it's in the Right state

Parameters

type L

Left

type R

Right

param either

Either to forall

param pred

Predicate

returns

True if the Either is in a Left state. True if the Either is in a Right state and the predicate returns True. False otherwise.

method Task<bool> forallAsync <L, R> (EitherAsync<L, R> either, Func<R, Task<bool>> pred) Source #

Invokes a predicate on the value of the Either if it's in the Right state

Parameters

type L

Left

type R

Right

param either

Either to forall

param pred

Predicate

returns

True if the Either is in a Left state. True if the Either is in a Right state and the predicate returns True. False otherwise.

method Task<bool> biforall <L, R> (EitherAsync<L, R> either, Func<R, bool> Right, Func<L, bool> Left) Source #

Invokes a predicate on the value of the Either if it's in the Right state

Parameters

type L

Left

type R

Right

param self

Either to forall

param Right

Right predicate

param Left

Left predicate

returns

True if the predicate returns True. True if the Either is in a bottom state.

method Task<bool> biforallAsync <L, R> (EitherAsync<L, R> either, Func<R, Task<bool>> RightAsync, Func<L, bool> Left) Source #

Invokes a predicate on the value of the Either if it's in the Right state

Parameters

type L

Left

type R

Right

param self

Either to forall

param Right

Right predicate

param Left

Left predicate

returns

True if the predicate returns True. True if the Either is in a bottom state.

method Task<bool> biforallAsync <L, R> (EitherAsync<L, R> either, Func<R, bool> Right, Func<L, Task<bool>> LeftAsync) Source #

Invokes a predicate on the value of the Either if it's in the Right state

Parameters

type L

Left

type R

Right

param self

Either to forall

param Right

Right predicate

param Left

Left predicate

returns

True if the predicate returns True. True if the Either is in a bottom state.

method Task<bool> biforallAsync <L, R> (EitherAsync<L, R> either, Func<R, Task<bool>> RightAsync, Func<L, Task<bool>> LeftAsync) Source #

Invokes a predicate on the value of the Either if it's in the Right state

Parameters

type L

Left

type R

Right

param self

Either to forall

param Right

Right predicate

param Left

Left predicate

returns

True if the predicate returns True. True if the Either is in a bottom state.

method Task<int> count <L, R> (EitherAsync<L, R> either) Source #

Counts the Either

Parameters

type L

Left

type R

Right

param either

Either to count

returns

1 if the Either is in a Right state, 0 otherwise.

method Task<bool> exists <L, R> (EitherAsync<L, R> either, Func<R, bool> pred) Source #

Invokes a predicate on the value of the Either if it's in the Right state

Parameters

type L

Left

type R

Right

param either

Either to check existence of

param pred

Predicate

returns

True if the Either is in a Right state and the predicate returns True. False otherwise.

method Task<bool> existsAsync <L, R> (EitherAsync<L, R> either, Func<R, Task<bool>> pred) Source #

Invokes a predicate on the value of the Either if it's in the Right state

Parameters

type L

Left

type R

Right

param either

Either to check existence of

param pred

Predicate

returns

True if the Either is in a Right state and the predicate returns True. False otherwise.

method Task<bool> biexists <L, R> (EitherAsync<L, R> either, Func<R, bool> Right, Func<L, bool> Left) Source #

Invokes a predicate on the value of the Either

Parameters

type L

Left

type R

Right

param self

Either to check existence of

param Right

Right predicate

param Left

Left predicate

returns

True if the predicate returns True. False otherwise or if the Either is in a bottom state.

method Task<bool> biexistsAsync <L, R> (EitherAsync<L, R> either, Func<R, Task<bool>> RightAsync, Func<L, bool> Left) Source #

Invokes a predicate on the value of the Either

Parameters

type L

Left

type R

Right

param self

Either to check existence of

param Right

Right predicate

param Left

Left predicate

returns

True if the predicate returns True. False otherwise or if the Either is in a bottom state.

method Task<bool> biexistsAsync <L, R> (EitherAsync<L, R> either, Func<R, bool> Right, Func<L, Task<bool>> LeftAsync) Source #

Invokes a predicate on the value of the Either

Parameters

type L

Left

type R

Right

param self

Either to check existence of

param Right

Right predicate

param Left

Left predicate

returns

True if the predicate returns True. False otherwise or if the Either is in a bottom state.

method Task<bool> biexistsAsync <L, R> (EitherAsync<L, R> either, Func<R, Task<bool>> RightAsync, Func<L, Task<bool>> LeftAsync) Source #

Invokes a predicate on the value of the Either

Parameters

type L

Left

type R

Right

param self

Either to check existence of

param Right

Right predicate

param Left

Left predicate

returns

True if the predicate returns True. False otherwise or if the Either is in a bottom state.

method EitherAsync<L, Ret> map <L, R, Ret> (EitherAsync<L, R> either, Func<R, Ret> f) Source #

Maps the value in the Either if it's in a Right state

Parameters

type L

Left

type R

Right

type Ret

Mapped Either type

param either

Either to map

param f

Map function

returns

Mapped EitherAsync

method EitherAsync<L, Ret> mapAsync <L, R, Ret> (EitherAsync<L, R> either, Func<R, Task<Ret>> f) Source #

Maps the value in the Either if it's in a Right state

Parameters

type L

Left

type R

Right

type Ret

Mapped Either type

param either

Either to map

param f

Map function

returns

Mapped EitherAsync

method EitherAsync<LRet, RRet> bimap <L, R, LRet, RRet> (EitherAsync<L, R> either, Func<R, RRet> Right, Func<L, LRet> Left) Source #

Bi-maps the value in the Either if it's in a Right state

Parameters

type L

Left

type R

Right

type LRet

Left return

type RRet

Right return

param self

Either to map

param Right

Right map function

param Left

Left map function

returns

Mapped EitherAsync

method EitherAsync<LRet, RRet> bimapAsync <L, R, LRet, RRet> (EitherAsync<L, R> either, Func<R, Task<RRet>> RightAsync, Func<L, LRet> Left) Source #

Bi-maps the value in the Either if it's in a Right state

Parameters

type L

Left

type R

Right

type LRet

Left return

type RRet

Right return

param self

Either to map

param Right

Right map function

param Left

Left map function

returns

Mapped EitherAsync

method EitherAsync<LRet, RRet> bimapAsync <L, R, LRet, RRet> (EitherAsync<L, R> either, Func<R, RRet> Right, Func<L, Task<LRet>> LeftAsync) Source #

Bi-maps the value in the Either if it's in a Right state

Parameters

type L

Left

type R

Right

type LRet

Left return

type RRet

Right return

param self

Either to map

param Right

Right map function

param Left

Left map function

returns

Mapped EitherAsync

method EitherAsync<LRet, RRet> bimapAsync <L, R, LRet, RRet> (EitherAsync<L, R> either, Func<R, Task<RRet>> RightAsync, Func<L, Task<LRet>> LeftAsync) Source #

Bi-maps the value in the Either if it's in a Right state

Parameters

type L

Left

type R

Right

type LRet

Left return

type RRet

Right return

param self

Either to map

param Right

Right map function

param Left

Left map function

returns

Mapped EitherAsync

method EitherAsync<L, Func<T2, R>> parmap <L, T1, T2, R> (EitherAsync<L, T1> either, Func<T1, T2, R> func) Source #

Partial application map

method EitherAsync<L, Func<T2, Func<T3, R>>> parmap <L, T1, T2, T3, R> (EitherAsync<L, T1> either, Func<T1, T2, T3, R> func) Source #

Partial application map

method EitherAsync<L, R> filter <L, R> (EitherAsync<L, R> either, Func<R, bool> pred) Source #

Filter the Either

This may give unpredictable results for a filtered value. The Either won't return true for IsLeft or IsRight. IsBottom is True if the value is filtered and that should be checked for.

Parameters

type L

Left

type R

Right

param self

Either to filter

param pred

Predicate function

returns

If the Either is in the Left state it is returned as-is. If in the Right state the predicate is applied to the Right value. If the predicate returns True the Either is returned as-is. If the predicate returns False the Either is returned in a 'Bottom' state.

method EitherAsync<L, R> filterAsync <L, R> (EitherAsync<L, R> either, Func<R, Task<bool>> pred) Source #

Filter the Either

This may give unpredictable results for a filtered value. The Either won't return true for IsLeft or IsRight. IsBottom is True if the value is filtered and that should be checked for.

Parameters

type L

Left

type R

Right

param self

Either to filter

param pred

Predicate function

returns

If the Either is in the Left state it is returned as-is. If in the Right state the predicate is applied to the Right value. If the predicate returns True the Either is returned as-is. If the predicate returns False the Either is returned in a 'Bottom' state.

method EitherAsync<L, Ret> bind <L, R, Ret> (EitherAsync<L, R> either, Func<R, EitherAsync<L, Ret>> binder) Source #

Parameters

type L

Left

type R

Right

type Ret
param either
param binder
returns

Bound EitherAsync

method Task<IEnumerable<Ret>> match <L, R, Ret> (IEnumerable<EitherAsync<L, R>> list, Func<R, Ret> Right, Func<L, Ret> Left) Source #

Match over a sequence of EitherAsyncs

Parameters

type L

Left

type R

Right

type Ret

Mapped type

param list

Sequence to match over

param Right

Right match function

param Left

Left match function

returns

Sequence of mapped values

method Task<Lst<R>> rightToList <L, R> (EitherAsync<L, R> either) Source #

Project the Either into a Lst R

Parameters

type L

Left

type R

Right

param either

Either to project

returns

If the Either is in a Right state, a Lst of R with one item. A zero length Lst R otherwise

method Task<Arr<R>> rightToArray <L, R> (EitherAsync<L, R> either) Source #

Project the Either into an ImmutableArray R

Parameters

type L

Left

type R

Right

param either

Either to project

returns

If the Either is in a Right state, a ImmutableArray of R with one item. A zero length ImmutableArray of R otherwise

method Task<Lst<L>> leftToList <L, R> (EitherAsync<L, R> either) Source #

Project the Either into a Lst L

Parameters

type L

Left

type R

Right

param either

Either to project

returns

If the Either is in a Left state, a Lst of L with one item. A zero length Lst L otherwise

method Task<Arr<L>> leftToArray <L, R> (EitherAsync<L, R> either) Source #

Project the Either into an array of L

Parameters

type L

Left

type R

Right

param either

Either to project

returns

If the Either is in a Right state, an array of L with one item. A zero length array of L otherwise

method Task<IQueryable<R>> rightToQuery <L, R> (EitherAsync<L, R> either) Source #

Project the Either into an IQueryable of R

Parameters

type L

Left

type R

Right

param either

Either to project

returns

If the Either is in a Right state, an IQueryable of R with one item. A zero length IQueryable R otherwise

method Task<IQueryable<L>> leftToQuery <L, R> (EitherAsync<L, R> either) Source #

Project the Either into an IQueryable of L

Parameters

type L

Left

type R

Right

param either

Either to project

returns

If the Either is in a Left state, an IQueryable of L with one item. A zero length IQueryable L otherwise

method Task<IEnumerable<L>> lefts <L, R> (IEnumerable<EitherAsync<L, R>> self) Source #

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 Task<Seq<L>> lefts <L, R> (Seq<EitherAsync<L, R>> self) Source #

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 Task<IEnumerable<R>> rights <L, R> (IEnumerable<EitherAsync<L, R>> self) Source #

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 Task<Seq<R>> rights <L, R> (Seq<EitherAsync<L, R>> self) Source #

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 Task<(IEnumerable<L> Lefts, IEnumerable<R> Rights)> partition <L, R> (IEnumerable<EitherAsync<L, R>> self) Source #

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 an enumerable of L and an enumerable of R

method Task<(Seq<L> Lefts, Seq<R> Rights)> partition <L, R> (Seq<EitherAsync<L, R>> self) Source #

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 an enumerable of L and an enumerable of R