LanguageExt.Core

LanguageExt.Core Monads Alternative Value Monads Try TryAsync

Contents

delegate TryAsync <A> Source #

The Try monad captures exceptions and uses them to cancel the computation. Primarily useful for expression based processing of errors.

To invoke directly, call x.Try()

Parameters

returns

A value that represents the outcome of the computation, either Success or Failure

class TryAsyncExtensions Source #

Extension methods for the TryAsync monad

Methods

method Aff<A> ToAff <A> (this TryAsync<A> ma) Source #

Convert the structure to an Aff

Parameters

returns

An Aff representation of the structure

method ValueTask<object> Case <A> (this TryAsync<A> ma) Source #

Use for pattern-matching the case of the target

TryAsync succeeds = result is A
TryAsync fails    = result is LanguageExt.Common.Error

method TryAsync<A> Memo <A> (this TryAsync<A> ma) Source #

Memoize the computation so that it's only run once

method TryAsync<A> Retry <A> (TryAsync<A> ma, int amount = 3) Source #

If the TryAsync fails, retry amount times

Parameters

type A

Type of bound value

param ma

TryAsync

param amount

Amount of retries

returns

TryAsync

method TryAsync<A> RetryBackOff <A> (TryAsync<A> ma, int backOffMilliSeconds, int amount = 3) Source #

If the TryOptionAsync fails, retry amount times whilst backing off backOffMilliSeconds

Parameters

type A

Type of bound value

param ma

TryOptionAsync

param backOffMilliSeconds

Amount of time in milliseconds to back-off upon failure. The back-off time is added to itself on each retry. i.e. 100, 200, 400, 800, 1600...

param amount

Amount of retries

returns

TryOptionAsync

method TaskAwaiter<Try<A>> GetAwaiter <A> (this TryAsync<A> ma) Source #

Custom awaiter that turns an TryAsync into an Try

method TryAsync<A> Strict <A> (this TryAsync<A> ma) Source #

Forces evaluation of the lazy TryAsync

Parameters

type A

Bound value type

param ma

Computation to evaluate

returns

The Try with the computation executed

method Task<bool> IsSucc <A> (this TryAsync<A> ma) Source #

Test if the TryAsync is in a success state

Parameters

type A

Bound value type

param ma

Computation to evaluate

returns

True if computation has succeeded

method Task<bool> IsFail <A> (this TryAsync<A> ma) Source #

Test if the TryAsync is in a faulted state

Parameters

type A

Bound value type

param ma

Computation to evaluate

returns

True if computation is faulted

method Task<Unit> IfSucc <A> (this TryAsync<A> self, Action<A> Succ) Source #

Invoke a delegate if the Try returns a value successfully

Parameters

param Succ

Delegate to invoke if successful

method Task<A> IfFail <A> (this TryAsync<A> self, A failValue) Source #

Return a default value if the Try fails

Parameters

param failValue

Default value to use on failure

returns

failValue on failure, the result of the Try otherwise

method Task<A> IfFail <A> (this TryAsync<A> self, Func<Task<A>> Fail) Source #

Invoke a delegate if the Try fails

Parameters

param Fail

Delegate to invoke on failure

returns

Result of the invocation of Fail on failure, the result of the Try otherwise

method Task<A> IfFail <A> (this TryAsync<A> self, Func<A> Fail) Source #

Invoke a delegate if the Try fails

Parameters

param Fail

Delegate to invoke on failure

returns

Result of the invocation of Fail on failure, the result of the Try otherwise

method Task<A> IfFail <A> (this TryAsync<A> self, Func<Exception, Task<A>> Fail) Source #

Returns the Succ(value) of the Try or a default if it's Fail

method Task<A> IfFail <A> (this TryAsync<A> self, Func<Exception, A> Fail) Source #

Returns the Succ(value) of the Try or a default if it's Fail

method ExceptionMatchAsync<A> IfFail <A> (this TryAsync<A> self) Source #

Provides a fluent exception matching interface which is invoked when the Try fails.

Parameters

returns

Fluent exception matcher

method Task<Unit> IfFail <A> (this TryAsync<A> self, Action<Exception> Fail) Source #

Invoke a delegate if the TryAsync computation fails

Parameters

type A

Type of bound value

param self

the TryAsync computation

param Fail

The delegate to invoke if the TryAsync computation fails

method Task<R> Match <A, R> (this TryAsync<A> self, Func<A, R> Succ, Func<Exception, R> Fail) Source #

Pattern matches the two possible states of the Try computation

Parameters

type R

Type of the resulting bound value

param Succ

Delegate to invoke if the Try computation completes successfully

param Fail

Delegate to invoke if the Try computation fails

returns

The result of either the Succ or Fail delegates

method Task<R> Match <A, R> (this TryAsync<A> self, Func<A, Task<R>> Succ, Func<Exception, R> Fail) Source #

Pattern matches the two possible states of the Try computation

Parameters

type R

Type of the resulting bound value

param Succ

Delegate to invoke if the Try computation completes successfully

param Fail

Delegate to invoke if the Try computation fails

returns

The result of either the Succ or Fail delegates

method Task<R> Match <A, R> (this TryAsync<A> self, Func<A, R> Succ, Func<Exception, Task<R>> Fail) Source #

Pattern matches the two possible states of the Try computation

Parameters

type R

Type of the resulting bound value

param Succ

Delegate to invoke if the Try computation completes successfully

param Fail

Delegate to invoke if the Try computation fails

returns

The result of either the Succ or Fail delegates

method Task<R> Match <A, R> (this TryAsync<A> self, Func<A, Task<R>> Succ, Func<Exception, Task<R>> Fail) Source #

Pattern matches the two possible states of the Try computation

Parameters

type R

Type of the resulting bound value

param Succ

Delegate to invoke if the Try computation completes successfully

param Fail

Delegate to invoke if the Try computation fails

returns

The result of either the Succ or Fail delegates

method Task<R> Match <A, R> (this TryAsync<A> self, Func<A, R> Succ, R Fail) Source #

Pattern matches the two possible states of the Try computation

Parameters

type R

Type of the resulting bound value

param Succ

Delegate to invoke if the Try computation completes successfully

param Fail

Default value to use if the Try computation fails

returns

The result of either the Succ delegate or the Fail value

method Task<R> Match <A, R> (this TryAsync<A> self, Func<A, Task<R>> Succ, R Fail) Source #

Pattern matches the two possible states of the Try computation

Parameters

type R

Type of the resulting bound value

param Succ

Delegate to invoke if the Try computation completes successfully

param Fail

Default value to use if the Try computation fails

returns

The result of either the Succ delegate or the Fail value

method Task<Unit> Match <A> (this TryAsync<A> self, Action<A> Succ, Action<Exception> Fail) Source #

Pattern matches the two possible states of the Try computation

Parameters

param Succ

Delegate to invoke if the Try computation completes successfully

param Fail

Delegate to invoke if the Try computation fails

method Task<Validation<FAIL, A>> ToValidation <A, FAIL> (this TryAsync<A> self, Func<Exception, FAIL> Fail) Source #

method Task<Option<A>> ToOption <A> (this TryAsync<A> self) Source #

method Task<OptionUnsafe<A>> ToOptionUnsafe <A> (this TryAsync<A> self) Source #

method TryOptionAsync<A> ToTryOption <A> (this TryAsync<A> self) Source #

method Task<EitherUnsafe<Error, A>> ToEitherUnsafe <A> (this TryAsync<A> self) Source #

method Task<EitherUnsafe<L, A>> ToEitherUnsafe <A, L> (this TryAsync<A> self, Func<Error, L> Fail) Source #

method EitherAsync<Error, A> ToEither <A> (this TryAsync<A> self) Source #

method EitherAsync<L, A> ToEither <A, L> (this TryAsync<A> self, Func<Error, L> Fail) Source #

method Task<A> IfFailThrow <A> (this TryAsync<A> self) Source #

method TryAsync<B> Select <A, B> (this TryAsync<A> self, Func<A, B> select) Source #

Maps the bound value

Parameters

type A

Type of the bound value

type B

Resulting bound value type

param self

Try computation

param select

Delegate to map the bound value

returns

Mapped Try computation

method TryAsync<B> Select <A, B> (this TryAsync<A> self, Func<A, Task<B>> select) Source #

Maps the bound value

Parameters

type A

Type of the bound value

type B

Resulting bound value type

param self

Try computation

param select

Delegate to map the bound value

returns

Mapped Try computation

method Task<Unit> Iter <A> (this TryAsync<A> self, Action<A> action) Source #

Apply Try values to a Try function of arity 2

Parameters

param self

Try function

param arg1

Try argument

param arg2

Try argument

returns

Returns the result of applying the Try arguments to the Try function

method Task<int> Count <A> (this TryAsync<A> self) Source #

Counts the number of bound values.

Parameters

type T

Type of the bound value

param self

TrTry computation

returns

1 if the Try computation is successful, 0 otherwise.

method Task<bool> ForAll <A> (this TryAsync<A> self, Func<A, bool> pred) Source #

Tests that a predicate holds for all values of the bound value T

Parameters

type T

Type of the bound value

param self

Try computation

param pred

Predicate to test the bound value against

returns

True if the predicate holds for the bound value, or if the Try computation fails. False otherwise.

method Task<bool> ForAllAsync <A> (this TryAsync<A> self, Func<A, Task<bool>> pred) Source #

Tests that a predicate holds for all values of the bound value T

Parameters

type T

Type of the bound value

param self

Try computation

param pred

Predicate to test the bound value against

returns

True if the predicate holds for the bound value, or if the Try computation fails. False otherwise.

method Task<S> Fold <A, S> (this TryAsync<A> self, S state, Func<S, A, S> folder) Source #

Parameters

param self

Try to fold

param state

Initial state

param folder

Fold function

returns

Folded state

method Task<S> FoldAsync <A, S> (this TryAsync<A> self, S state, Func<S, A, Task<S>> folder) Source #

Parameters

param self

Try to fold

param state

Initial state

param folder

Fold function

returns

Folded state

method Task<S> BiFold <A, S> (this TryAsync<A> self, S state, Func<S, A, S> Succ, Func<S, Exception, S> Fail) Source #

Parameters

param self

Try to fold

param state

Initial state

param Succ

Fold function for Success

param Fail

Fold function for Failure

returns

Folded state

method Task<S> BiFold <A, S> (this TryAsync<A> self, S state, Func<S, A, S> Succ, Func<S, Exception, Task<S>> Fail) Source #

Parameters

param self

Try to fold

param state

Initial state

param Succ

Fold function for Success

param Fail

Fold function for Failure

returns

Folded state

method Task<S> BiFold <A, S> (this TryAsync<A> self, S state, Func<S, A, Task<S>> Succ, Func<S, Exception, S> Fail) Source #

Parameters

param self

Try to fold

param state

Initial state

param Succ

Fold function for Success

param Fail

Fold function for Failure

returns

Folded state

method Task<S> BiFold <A, S> (this TryAsync<A> self, S state, Func<S, A, Task<S>> Succ, Func<S, Exception, Task<S>> Fail) Source #

Parameters

param self

Try to fold

param state

Initial state

param Succ

Fold function for Success

param Fail

Fold function for Failure

returns

Folded state

method Task<bool> Exists <A> (this TryAsync<A> self, Func<A, bool> pred) Source #

Tests that a predicate holds for any value of the bound value T

Parameters

type A

Type of the bound value

param self

Try computation

param pred

Predicate to test the bound value against

returns

True if the predicate holds for the bound value. False otherwise.

method Task<bool> ExistsAsync <A> (this TryAsync<A> self, Func<A, Task<bool>> pred) Source #

Tests that a predicate holds for any value of the bound value T

Parameters

type A

Type of the bound value

param self

Try computation

param pred

Predicate to test the bound value against

returns

True if the predicate holds for the bound value. False otherwise.

method TryAsync<A> Do <A> (this TryAsync<A> ma, Action<A> f) Source #

Impure iteration of the bound value in the structure

Parameters

returns

Returns the original unmodified structure

method TryAsync<B> Map <A, B> (this TryAsync<A> self, Func<A, B> f) Source #

Maps the bound value

Parameters

type A

Type of the bound value

type B

Resulting bound value type

param self

Try computation

param mapper

Delegate to map the bound value

returns

Mapped Try computation

method TryAsync<B> MapAsync <A, B> (this TryAsync<A> self, Func<A, Task<B>> f) Source #

Maps the bound value

Parameters

type A

Type of the bound value

type B

Resulting bound value type

param self

Try computation

param mapper

Delegate to map the bound value

returns

Mapped Try computation

method TryAsync<B> BiMap <A, B> (this TryAsync<A> self, Func<A, B> Succ, Func<Exception, B> Fail) Source #

Maps the bound value

Parameters

type A

Type of the bound value

type B

Resulting bound value type

param self

Try computation

param Succ

Delegate to map the bound value

param Fail

Delegate to map the exception to the desired bound result type

returns

Mapped Try computation

method TryAsync<B> BiMap <A, B> (this TryAsync<A> self, Func<A, Task<B>> Succ, Func<Exception, B> Fail) Source #

Maps the bound value

Parameters

type A

Type of the bound value

type B

Resulting bound value type

param self

Try computation

param Succ

Delegate to map the bound value

param Fail

Delegate to map the exception to the desired bound result type

returns

Mapped Try computation

method TryAsync<B> BiMap <A, B> (this TryAsync<A> self, Func<A, B> Succ, Func<Exception, Task<B>> Fail) Source #

Maps the bound value

Parameters

type A

Type of the bound value

type B

Resulting bound value type

param self

Try computation

param Succ

Delegate to map the bound value

param Fail

Delegate to map the exception to the desired bound result type

returns

Mapped Try computation

method TryAsync<B> BiMap <A, B> (this TryAsync<A> self, Func<A, Task<B>> Succ, Func<Exception, Task<B>> Fail) Source #

Maps the bound value

Parameters

type A

Type of the bound value

type B

Resulting bound value type

param self

Try computation

param Succ

Delegate to map the bound value

param Fail

Delegate to map the exception to the desired bound result type

returns

Mapped Try computation

method TryAsync<Func<B, R>> ParMap <A, B, R> (this TryAsync<A> self, Func<A, B, R> func) Source #

Partial application map

method TryAsync<Func<B, Func<C, R>>> ParMap <A, B, C, R> (this TryAsync<A> self, Func<A, B, C, R> func) Source #

Partial application map

method TryAsync<A> Filter <A> (this TryAsync<A> self, Func<A, bool> pred) Source #

method TryAsync<A> Filter <A> (this TryAsync<A> self, Func<A, Task<bool>> pred) Source #

method TryAsync<A> BiFilter <A> (this TryAsync<A> self, Func<A, bool> Succ, Func<Exception, bool> Fail) Source #

method TryAsync<A> BiFilter <A> (this TryAsync<A> self, Func<A, Task<bool>> Succ, Func<Exception, bool> Fail) Source #

method TryAsync<A> BiFilter <A> (this TryAsync<A> self, Func<A, bool> Succ, Func<Exception, Task<bool>> Fail) Source #

method TryAsync<A> BiFilter <A> (this TryAsync<A> self, Func<A, Task<bool>> Succ, Func<Exception, Task<bool>> Fail) Source #

method TryAsync<A> Where <A> (this TryAsync<A> self, Func<A, bool> pred) Source #

method TryAsync<A> Where <A> (this TryAsync<A> self, Func<A, Task<bool>> pred) Source #

method TryAsync<B> Bind <A, B> (this TryAsync<A> ma, Func<A, TryAsync<B>> f) Source #

method TryAsync<B> BindAsync <A, B> (this TryAsync<A> ma, Func<A, Task<TryAsync<B>>> f) Source #

method TryAsync<R> BiBind <A, R> (this TryAsync<A> self, Func<A, TryAsync<R>> Succ, Func<Exception, TryAsync<R>> Fail) Source #

method TryAsync<A> Plus <A> (this TryAsync<A> ma, TryAsync<A> mb) Source #

method TryAsync<A> PlusFirst <A> (this TryAsync<A> ma, TryAsync<A> mb) Source #

method Task<Seq<A>> ToSeq <A> (this TryAsync<A> self) Source #

method Task<Seq<A>> AsEnumerable <A> (this TryAsync<A> self) Source #

method Task<Lst<A>> ToList <A> (this TryAsync<A> self) Source #

method Task<Arr<A>> ToArray <A> (this TryAsync<A> self) Source #

method TryAsyncSuccContext<A, R> Succ <A,R> (this TryAsync<A> self, Func<A, R> succHandler) Source #

method TryAsyncSuccUnitContext<A> Succ <A> (this TryAsync<A> self, Action<A> succHandler) Source #

method Task<string> AsString <A> (this TryAsync<A> self) Source #

method TryAsync<C> SelectMany <A, B, C> ( this TryAsync<A> ma, Func<A, TryAsync<B>> bind, Func<A, B, C> project) Source #

method TryAsync<C> SelectMany <A, B, C> ( this TryAsync<A> ma, Func<A, Task<TryAsync<B>>> bind, Func<A, B, C> project) Source #

method TryAsync<C> SelectMany <A, B, C> ( this TryAsync<A> ma, Func<A, Task<TryAsync<B>>> bind, Func<A, B, Task<C>> project) Source #

method TryAsync<C> SelectMany <A, B, C> ( this TryAsync<A> ma, Func<A, TryAsync<B>> bind, Func<A, B, Task<C>> project) Source #

method TryAsync<V> Join <A, U, K, V> ( this TryAsync<A> self, TryAsync<U> inner, Func<A, K> outerKeyMap, Func<U, K> innerKeyMap, Func<A, U, V> project) Source #

method Task<Result<T>> Try <T> (this TryAsync<T> self) Source #

method TryAsync<U> Use <T, U> (this TryAsync<T> self, Func<T, U> select) Source #

where T : IDisposable

method TryAsync<U> Use <T, U> (this TryAsync<T> self, Func<T, TryAsync<U>> select) Source #

where T : IDisposable

method Task<int> Sum (this TryAsync<int> self) Source #

method TryAsync<T> Flatten <T> (this TryAsync<TryAsync<T>> self) Source #

method TryAsync<T> Flatten <T> (this TryAsync<TryAsync<TryAsync<T>>> self) Source #

method TryAsync<T> Flatten <T> (this TryAsync<TryAsync<TryAsync<TryAsync<T>>>> self) Source #

method TryAsync<B> Apply <A, B> (this TryAsync<Func<A, B>> fab, TryAsync<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 TryAsync<B> Apply <A, B> (this Func<A, B> fab, TryAsync<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 TryAsync<C> Apply <A, B, C> (this TryAsync<Func<A, B, C>> fabc, TryAsync<A> fa, TryAsync<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 TryAsync<C> Apply <A, B, C> (this Func<A, B, C> fabc, TryAsync<A> fa, TryAsync<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 TryAsync<Func<B, C>> Apply <A, B, C> (this TryAsync<Func<A, B, C>> fabc, TryAsync<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 TryAsync<Func<B, C>> Apply <A, B, C> (this Func<A, B, C> fabc, TryAsync<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 TryAsync<Func<B, C>> Apply <A, B, C> (this TryAsync<Func<A, Func<B, C>>> fabc, TryAsync<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 TryAsync<Func<B, C>> Apply <A, B, C> (this Func<A, Func<B, C>> fabc, TryAsync<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 TryAsync<B> Action <A, B> (this TryAsync<A> fa, TryAsync<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<int> Compare <ORD, A> (this TryAsync<A> lhs, TryAsync<A> rhs) Source #

where ORD : struct, Ord<A>

Compare the bound value of Try(x) to Try(y). If either of the

Parameters

param lhs

Left-hand side of the operation

param rhs

Right-hand side of the operation

returns

1 if lhs > rhs, 0 if lhs == rhs, -1 if lhs < rhs

method TryAsync<A> Append <SEMI, A> (this TryAsync<A> lhs, TryAsync<A> rhs) Source #

where SEMI : struct, Semigroup<A>

Append the bound value of TryAsync(x) to TryAsync(y). If either of the Trys are Fail then the result is Fail

Parameters

param lhs

Left-hand side of the operation

param rhs

Right-hand side of the operation

returns

lhs ++ rhs

method TryAsync<A> Add <ARITH, A> (this TryAsync<A> lhs, TryAsync<A> rhs) Source #

where ARITH : struct, Arithmetic<A>

Add the bound value of Try(x) to Try(y). If either of the Trys are Fail then the result is Fail

Parameters

param lhs

Left-hand side of the operation

param rhs

Right-hand side of the operation

returns

lhs + rhs

method TryAsync<A> Subtract <ARITH, A> (this TryAsync<A> lhs, TryAsync<A> rhs) Source #

where ARITH : struct, Arithmetic<A>

Find the subtract of the bound value of Try(x) and Try(y). If either of the Trys are Fail then the result is Fail

Parameters

param lhs

Left-hand side of the operation

param rhs

Right-hand side of the operation

returns

lhs + rhs

method TryAsync<A> Product <ARITH, A> (this TryAsync<A> lhs, TryAsync<A> rhs) Source #

where ARITH : struct, Arithmetic<A>

Multiply the bound value of Try(x) and Try(y). If either of the Trys are Fail then the result is Fail

Parameters

param lhs

Left-hand side of the operation

param rhs

Right-hand side of the operation

returns

lhs + rhs

method TryAsync<A> Divide <NUM, A> (this TryAsync<A> lhs, TryAsync<A> rhs) Source #

where NUM : struct, Num<A>

Multiply the bound value of Try(x) and Try(y). If either of the Trys are Fail then the result is Fail

Parameters

param lhs

Left-hand side of the operation

param rhs

Right-hand side of the operation

returns

lhs + rhs

method Task<A?> ToNullable <A> (this TryAsync<A> ma) Source #

where A : struct

Convert the Try type to a Nullable of A

Parameters

type A

Type of the bound value

param ma

Try to convert

returns

Nullable of A

class Prelude Source #

Methods

method TryAsync<A> TryAsync <A> (Func<Task<A>> f) Source #

TryAsync constructor function

Parameters

type A

Bound value type

param f

Function to run asynchronously

returns

A lifted operation that returns a value of A

method TryAsync<A> TryAsync <A> (Task<A> v) Source #

TryAsync constructor function

Parameters

type A

Bound value type

param v

Task to run asynchronously

returns

A lifted operation that returns a value of A

method TryAsync<A> TryAsync <A> (A v) Source #

TryAsync identity constructor function

Parameters

type A

Bound value type

param v

Bound value to return

returns

A lifted operation that returns a value of A

method TryAsync<A> TryAsyncSucc <A> (A v) Source #

TryAsync identity constructor function

Parameters

type A

Bound value type

param v

Bound value to return

returns

A lifted operation that returns a value of A

method TryAsync<A> TryAsync <A> (Exception ex) Source #

TryOptionAsync constructor function

Parameters

type A

Bound value type

param v

Bound value to return

returns

A lifted operation that returns a value of A

method TryAsync<A> TryAsyncFail <A> (Exception ex) Source #

TryOptionAsync constructor function

Parameters

type A

Bound value type

param v

Bound value to return

returns

A lifted operation that returns a value of A

method TryAsync<A> append <SEMI, A> (TryAsync<A> lhs, TryAsync<A> rhs) Source #

where SEMI : struct, Semigroup<A>

Append the bound value of TryAsync(x) to TryAsync(y). If either of the Trys are Fail then the result is Fail

Parameters

param lhs

Left-hand side of the operation

param rhs

Right-hand side of the operation

returns

lhs ++ rhs

method TryAsync<A> add <NUM, A> (TryAsync<A> lhs, TryAsync<A> rhs) Source #

where NUM : struct, Num<A>

Add the bound value of TryAsync(x) to TryAsync(y). If either of the Trys are Fail then the result is Fail

Parameters

param lhs

Left-hand side of the operation

param rhs

Right-hand side of the operation

returns

lhs + rhs

method TryAsync<T> subtract <NUM, T> (TryAsync<T> lhs, TryAsync<T> rhs) Source #

where NUM : struct, Num<T>

Subtract the TryAsync(x) from TryAsync(y). If either of the Trys throw then the result is Fail For numeric values the behaviour is to find the subtract between the Trys (lhs - rhs) For Lst values the behaviour is to remove items in the rhs from the lhs For Map or Set values the behaviour is to remove items in the rhs from the lhs Otherwise if the R type derives from ISubtractable then the behaviour is to call lhs.Subtract(rhs);

Parameters

param lhs

Left-hand side of the operation

param rhs

Right-hand side of the operation

returns

lhs - rhs

method TryAsync<T> product <NUM, T> (TryAsync<T> lhs, TryAsync<T> rhs) Source #

where NUM : struct, Num<T>

Find the product of TryAsync(x) and TryAsync(y). If either of the Trys throw then the result is Fail For numeric values the behaviour is to multiply the Trys (lhs * rhs) For Lst values the behaviour is to multiply all combinations of values in both lists to produce a new list Otherwise if the R type derives from IMultiplicable then the behaviour is to call lhs.Multiply(rhs);

Parameters

param lhs

Left-hand side of the operation

param rhs

Right-hand side of the operation

returns

lhs * rhs

method TryAsync<T> divide <NUM, T> (TryAsync<T> lhs, TryAsync<T> rhs) Source #

where NUM : struct, Num<T>

Divide Try(x) by Try(y). If either of the Trys throw then the result is Fail For numeric values the behaviour is to divide the Trys (lhs / rhs) For Lst values the behaviour is to divide all combinations of values in both lists to produce a new list Otherwise if the R type derives from IDivisible then the behaviour is to call lhs.Divide(rhs);

Parameters

param lhs

Left-hand side of the operation

param rhs

Right-hand side of the operation

returns

lhs / rhs

method TryAsync<B> apply <A, B> (TryAsync<Func<A, B>> fab, TryAsync<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 TryAsync<B> apply <A, B> (Func<A, B> fab, TryAsync<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 TryAsync<C> apply <A, B, C> (TryAsync<Func<A, B, C>> fabc, TryAsync<A> fa, TryAsync<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 TryAsync<C> apply <A, B, C> (Func<A, B, C> fabc, TryAsync<A> fa, TryAsync<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 TryAsync<Func<B, C>> apply <A, B, C> (TryAsync<Func<A, B, C>> fabc, TryAsync<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 TryAsync<Func<B, C>> apply <A, B, C> (Func<A, B, C> fabc, TryAsync<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 TryAsync<Func<B, C>> apply <A, B, C> (TryAsync<Func<A, Func<B, C>>> fabc, TryAsync<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 TryAsync<Func<B, C>> apply <A, B, C> (Func<A, Func<B, C>> fabc, TryAsync<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 TryAsync<B> action <A, B> (TryAsync<A> fa, TryAsync<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 TryAsync<bool> isSucc <T> (TryAsync<T> self) Source #

Test if the TryAsync computation is successful

Parameters

type T

Type of the bound value

param self

TryAsync computation to test

returns

True if successful

method TryAsync<bool> isFail <T> (TryAsync<T> self) Source #

Test if the TryAsync computation fails

Parameters

type T

Type of the bound value

param self

TryAsync computation to test

returns

True if fails

method Task<Unit> ifSucc <T> (TryAsync<T> self, Action<T> Succ) Source #

Invoke a delegate if the TryAsync returns a value successfully

Parameters

type T

Type of the bound value

param self

TryAsync computation

param Succ

Delegate to invoke if successful

method Task<T> ifFail <T> (TryAsync<T> self, Func<T> Fail) Source #

Invoke a delegate if the TryAsync fails

Parameters

type T

Type of the bound value

param value

TryAsync computation

param Fail

Delegate to invoke on failure

returns

Result of the invocation of Fail on failure, the result of the TryAsync otherwise

method Task<T> ifFail <T> (TryAsync<T> self, T failValue) Source #

Return a default value if the TryAsync fails

Parameters

type T

Type of the bound value

param self

TryAsync computation

param failValue

Default value to use on failure

returns

failValue on failure, the result of the TryAsync otherwise

method ExceptionMatchAsync<T> ifFail <T> (TryAsync<T> self) Source #

Provides a fluent exception matching interface which is invoked when the Try fails.

Parameters

type T

Type of the bound value

param self

TryAsync computation

returns

Fluent exception matcher

method Task<Unit> ifFail <T> (TryAsync<T> self, Action<Exception> Fail) Source #

Invoke a delegate if the TryAsync computation fails

Parameters

type T

Type of bound value

param self

The TryAsync computation

param Fail

The delegate to invoke if the TryAsync computation fails

method TryAsync<Exception> failed <T> (TryAsync<T> self) Source #

Maps the bound value to the resulting exception (if the TryAsync computation fails). If the TryAsync computation succeeds then a NotSupportedException is used.

Parameters

type T

Type of the bound value

param self

TryAsync computation

returns

Try of Exception

method TryAsync<T> flatten <T> (TryAsync<TryAsync<T>> self) Source #

Flattens nested TryAsync computations

Parameters

type T

Type of the bound value

param self

TryAsync computation

returns

Flattened TryAsync computation

method TryAsync<T> flatten <T> (TryAsync<TryAsync<TryAsync<T>>> self) Source #

Flattens nested TryAsync computations

Parameters

type T

Type of the bound value

param self

TryAsync computation

returns

Flattened TryAsync computation

method TryAsync<T> flatten <T> (TryAsync<TryAsync<TryAsync<TryAsync<T>>>> self) Source #

Flattens nested TryAsync computations

Parameters

type T

Type of the bound value

param self

TryAsync computation

returns

Flattened TryAsync computation

method Task<R> match <T, R> (TryAsync<T> self, Func<T, R> Succ, Func<Exception, R> Fail) Source #

Pattern matches the two possible states of the TryAsync computation

Parameters

type T

Type of the bound value

type R

Type of the resulting bound value

param self

Try computation

param Succ

Delegate to invoke if the TryAsync computation completes successfully

param Fail

Delegate to invoke if the TryAsync computation fails

returns

The result of either the Succ or Fail delegates

method Task<R> match <T, R> (TryAsync<T> self, Func<T, R> Succ, R Fail) Source #

Pattern matches the two possible states of the TryAsync computation

Parameters

type T

Type of the bound value

type R

Type of the resulting bound value

param self

TryAsync computation

param Succ

Delegate to invoke if the TryAsync computation completes successfully

param Fail

Default value to use if the TryAsync computation fails

returns

The result of either the Succ delegate or the Fail value

method Task<Unit> match <T> (TryAsync<T> self, Action<T> Succ, Action<Exception> Fail) Source #

Pattern matches the two possible states of the TryAsync computation

Parameters

type T

Type of the bound value

param self

TryAsync computation

param Succ

Delegate to invoke if the TryAsync computation completes successfully

param Fail

Delegate to invoke if the TryAsync computation fails

method Task<Unit> iter <T> (TryAsync<T> self, Action<T> action) Source #

Invokes a delegate with the result of the TryAsync computation if it is successful.

Parameters

type T

Type of the bound value

param self

TryAsync computation

param action

Delegate to invoke on successful invocation of the TryAsync computation

method Task<S> fold <S, T> (TryAsync<T> self, S state, Func<S, T, S> folder) Source #

Folds the value of TryAsync into an S. wikipedia.org/wiki/Fold_(higher-order_function)

Parameters

param self

TryAsync to fold

param state

Initial state

param folder

Fold function

returns

Folded state

method Task<S> fold <S, T> (TryAsync<T> self, S state, Func<S, T, S> Succ, Func<S, Exception, S> Fail) Source #

Folds the result of TryAsync into an S. wikipedia.org/wiki/Fold_(higher-order_function)

Parameters

param tryDel

TryAsync to fold

param state

Initial state

param Succ

Fold function when TryAsync succeeds

param Fail

Fold function when TryAsync fails

returns

Folded state

method Task<bool> forall <T> (TryAsync<T> self, Func<T, bool> pred) Source #

Tests that a predicate holds for all values of the bound value T

Parameters

type T

Type of the bound value

param self

TryAsync computation

param pred

Predicate to test the bound value against

returns

True if the predicate holds for the bound value, or if the TryAsync computation fails. False otherwise.

method Task<int> count <T> (TryAsync<T> self) Source #

Counts the number of bound values.

Parameters

type T

Type of the bound value

param self

TryAsync computation

returns

1 if the TryAsync computation is successful, 0 otherwise.

method Task<bool> exists <T> (TryAsync<T> self, Func<T, bool> pred) Source #

Tests that a predicate holds for any value of the bound value T

Parameters

type T

Type of the bound value

param self

Try computation

param pred

Predicate to test the bound value against

returns

True if the predicate holds for the bound value. False otherwise.

method TryAsync<R> map <T, R> (TryAsync<T> self, Func<T, R> mapper) Source #

Maps the bound value

Parameters

type T

Type of the bound value

type R

Resulting bound value type

param self

TryAsync computation

param mapper

Delegate to map the bound value

returns

Mapped Try computation

method TryAsync<R> bimap <T, R> (TryAsync<T> tryDel, Func<T, R> Succ, Func<Exception, R> Fail) Source #

Maps the bound value

Parameters

type T

Type of the bound value

type R

Resulting bound value type

param self

TryAsync computation

param Succ

Delegate to map the bound value

param Fail

Delegate to map the exception to the desired bound result type

returns

Mapped Try computation

method TryAsync<Func<T2, R>> parmap <T1, T2, R> (TryAsync<T1> self, Func<T1, T2, R> func) Source #

Partial application map

method TryAsync<Func<T2, Func<T3, R>>> parmap <T1, T2, T3, R> (TryAsync<T1> self, Func<T1, T2, T3, R> func) Source #

Partial application map

method TryAsync<T> filter <T> (TryAsync<T> self, Func<T, bool> pred) Source #

method TryAsync<T> bifilter <T> (TryAsync<T> self, Func<T, bool> Succ, Func<Exception, bool> Fail) Source #

method TryAsync<R> bind <T, R> (TryAsync<T> tryDel, Func<T, TryAsync<R>> binder) Source #

method TryAsync<R> bibind <T, R> (TryAsync<T> self, Func<T, TryAsync<R>> Succ, Func<Exception, TryAsync<R>> Fail) Source #

method TryAsync<A> plus <A> (TryAsync<A> ma, TryAsync<A> mb) Source #

method TryAsync<A> plusFirst <A> (TryAsync<A> ma, TryAsync<A> mb) Source #

method Task<Lst<T>> toList <T> (TryAsync<T> tryDel) Source #

method Task<Arr<T>> toArray <T> (TryAsync<T> tryDel) Source #

method TryAsync<T> tryfun <T> (Func<TryAsync<T>> f) Source #

method TryAsync<A> choice <A> (TryAsync<A> ma, params TryAsync<A>[] tail) Source #

Returns the first successful computation

Parameters

type A

Bound value

param ma

The first computation to run

param tail

The rest of the computations to run

returns

The first computation that succeeds

method TryAsync<A> choice <A> (Seq<TryAsync<A>> xs) Source #

Returns the first successful computation

Parameters

type A

Bound value

param xs

Sequence of computations to run

returns

The first computation that succeeds

struct TryAsyncSuccContext <A, B> Source #

Methods

method Task<B> Fail (Func<Exception, B> f) Source #

method Task<B> Fail (Func<Exception, Task<B>> f) Source #

method Task<B> Fail (B failValue) Source #

method Task<B> Fail (Task<B> failValue) Source #

struct TryAsyncSuccUnitContext <A> Source #

Methods

method Task<Unit> Fail (Action<Exception> f) Source #