LanguageExt.Core

LanguageExt.Core Monads Alternative Value Monads Try Try

Contents

class TaskTryExtensions Source #

Methods

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

Convert a Task<Try> to a TryAsync

method TryAsync<Unit> ToAsync (this Try<Task> self) Source #

Convert a Task to a TryAsync

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

Convert a Task<Try> to a TryAsync

method Eff<A> ToEff <A> (this Try<A> ma) Source #

Convert the structure to an Eff

Parameters

returns

An Eff representation of the structure

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

Convert the structure to an Aff

Parameters

returns

An Aff representation of the structure

method Task<Unit> IfSucc <A> (this Task<Try<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 Task<Try<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 Task<Try<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 Task<Try<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 Task<Try<A>> self) Source #

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

Parameters

returns

Fluent exception matcher

method Task<R> Match <A, R> (this Task<Try<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 Task<Try<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<Unit> Match <A> (this Task<Try<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<R> Match <A, R> (this Task<Try<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 Task<Try<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 Task<Try<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 TryAsync<A> Memo <A> (this Task<Try<A>> self) Source #

Memoise the try

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

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

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

method Task<Try<B>> Select <A, B> (this Task<Try<A>> self, Func<A, B> f) Source #

Map the bound value from A to B

Parameters

type A

Bound value type

type B

Returned bound value type

param self

This

param f

Mapping function

returns

Mapped Try

method Task<Try<B>> Select <A, B> (this Task<Try<A>> self, Func<A, Task<B>> f) Source #

Map the bound value from A to Task of B

Parameters

type A

Bound value type

type B

Returned bound value type

param self

This

param f

Mapping function

returns

Returns an asynchronous Try

method Task<Unit> Iter <A> (this Task<Try<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 Task<Try<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 Task<Try<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 Task<Try<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 Task<Try<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 Task<Try<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 Task<Try<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 Task<Try<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 Task<Try<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 Task<Try<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 Task<Try<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 Task<Try<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 Task<Try<R>> Map <A, R> (this Task<Try<A>> self, Func<A, R> mapper) Source #

Maps the bound value

Parameters

type A

Type of the bound value

type R

Resulting bound value type

param self

Try computation

param mapper

Delegate to map the bound value

returns

Mapped Try computation

method Task<Try<R>> Map <A, R> (this Task<Try<A>> self, Func<A, Task<R>> mapper) Source #

Maps the bound value

Parameters

type A

Type of the bound value

type R

Resulting bound value type

param self

Try computation

param mapper

Delegate to map the bound value

returns

Mapped Try computation

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

Maps the bound value

Parameters

type A

Type of the bound value

type R

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 Task<Try<R>> BiMap <A, R> (this Task<Try<A>> self, Func<A, Task<R>> Succ, Func<Exception, R> Fail) Source #

Maps the bound value

Parameters

type A

Type of the bound value

type R

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 Task<Try<R>> BiMap <A, R> (this Task<Try<A>> self, Func<A, R> Succ, Func<Exception, Task<R>> Fail) Source #

Maps the bound value

Parameters

type A

Type of the bound value

type R

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 Task<Try<R>> BiMap <A, R> (this Task<Try<A>> self, Func<A, Task<R>> Succ, Func<Exception, Task<R>> Fail) Source #

Maps the bound value

Parameters

type A

Type of the bound value

type R

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 Task<Try<A>> Filter <A> (this Task<Try<A>> self, Func<A, bool> pred) Source #

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

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

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

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

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

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

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

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

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

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

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

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

method Task<Try<B>> Bind <A, B> (this Task<Try<A>> self, Func<A, Task<Try<B>>> binder) Source #

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

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

method Task<int> Compare <ORD, A> (this Task<Try<A>> lhs, Task<Try<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> Add <NUM, A> (this Task<Try<A>> lhs, Task<Try<A>> rhs) Source #

where NUM : struct, Num<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 <NUM, A> (this Task<Try<A>> lhs, Task<Try<A>> rhs) Source #

where NUM : struct, Num<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 <NUM, A> (this Task<Try<A>> lhs, Task<Try<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 TryAsync<A> Divide <NUM, A> (this Task<Try<A>> lhs, Task<Try<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 Task<Try<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

delegate Try <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 TryExtensionsAsync Source #

Extension methods for the Try monad

Methods

method TryAsync<A> ToAsync <A> (this Try<A> self) Source #

Converts this Try to a TryAsync

Parameters

type A

Bound value type

param self

This

returns

Asynchronous Try

method Task<Unit> IfSuccAsync <A> (this Try<A> self, Action<A> Succ) Source #

Runs the Try asynchronously. Invoke a delegate if the Try returns a value successfully

Parameters

param Succ

Delegate to invoke if successful

method Task<A> IfFailAsync <A> (this Try<A> self, A failValue) Source #

Runs the Try asynchronously. 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> IfFailAsync <A> (this Try<A> self, Func<Task<A>> Fail) Source #

Runs the Try asynchronously. 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> IfFailAsync <A> (this Try<A> self, Func<Exception, Task<A>> Fail) Source #

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

method ExceptionMatchAsync<A> IfFailAsync <A> (this Try<A> self) Source #

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

Parameters

returns

Fluent exception matcher

method Task<R> MatchAsync <A, R> (this Try<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> MatchAsync <A, R> (this Try<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<Unit> MatchAsync <A> (this Try<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<R> MatchAsync <A, R> (this Try<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> MatchAsync <A, R> (this Try<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> MatchAsync <A, R> (this Try<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<Option<A>> ToOptionAsync <A> (this Try<A> self) Source #

method Task<OptionUnsafe<A>> ToOptionUnsafeAsync <A> (this Try<A> self) Source #

method EitherAsync<Error, A> ToEitherAsync <A> (this Try<A> self) Source #

method Task<EitherUnsafe<Error, A>> ToEitherUnsafeAsync <A> (this Try<A> self) Source #

method Task<A> IfFailThrowAsync <A> (this Try<A> self) Source #

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

Invokes the delegate if the Try computation fails

Parameters

type A

Type of bound value

param self

The Try computation

param Fail

The delegate to invoke if the Try computation fails

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

Map the bound value from A to Task of B

Parameters

type A

Bound value type

type B

Returned bound value type

param self

This

param f

Mapping function

returns

Returns an asynchronous Try

method Task<Unit> IterAsync <A> (this Try<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> CountAsync <A> (this Try<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> ForAllAsync <A> (this Try<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 Try<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> FoldAsync <A, S> (this Try<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 Try<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> BiFoldAsync <A, S> (this Try<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> BiFoldAsync <A, S> (this Try<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> BiFoldAsync <A, S> (this Try<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> BiFoldAsync <A, S> (this Try<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> ExistsAsync <A> (this Try<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 Try<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<R> MapAsync <A, R> (this Try<A> self, Func<A, R> mapper) Source #

Maps the bound value

Parameters

type A

Type of the bound value

type R

Resulting bound value type

param self

Try computation

param mapper

Delegate to map the bound value

returns

Mapped Try computation

method TryAsync<R> MapAsync <A, R> (this Try<A> self, Func<A, Task<R>> mapper) Source #

Maps the bound value

Parameters

type A

Type of the bound value

type R

Resulting bound value type

param self

Try computation

param mapper

Delegate to map the bound value

returns

Mapped Try computation

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

Maps the bound value

Parameters

type A

Type of the bound value

type R

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<R> BiMapAsync <A, R> (this Try<A> self, Func<A, Task<R>> Succ, Func<Exception, R> Fail) Source #

Maps the bound value

Parameters

type A

Type of the bound value

type R

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<R> BiMapAsync <A, R> (this Try<A> self, Func<A, R> Succ, Func<Exception, Task<R>> Fail) Source #

Maps the bound value

Parameters

type A

Type of the bound value

type R

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<R> BiMapAsync <A, R> (this Try<A> self, Func<A, Task<R>> Succ, Func<Exception, Task<R>> Fail) Source #

Maps the bound value

Parameters

type A

Type of the bound value

type R

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<A> FilterAsync <A> (this Try<A> self, Func<A, bool> pred) Source #

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

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

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

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

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

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

method Task<Seq<A>> ToSeqAsync <A> (this Try<A> self) Source #

method Task<Seq<A>> AsEnumerableAsync <A> (this Try<A> self) Source #

method Task<Lst<A>> ToListAsync <A> (this Try<A> self) Source #

method Task<Arr<A>> ToArrayAsync <A> (this Try<A> self) Source #

method Task<string> AsStringAsync <A> (this Try<A> self) Source #

method Task<int> SumAsync (this Try<int> self) Source #

method Task<int> CompareAsync <ORD, A> (this Try<A> lhs, Try<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> AppendAsync <SEMI, A> (this Try<A> lhs, Try<A> rhs) Source #

where SEMI : struct, Semigroup<A>

Append 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> AddAsync <NUM, A> (this Try<A> lhs, Try<A> rhs) Source #

where NUM : struct, Num<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> SubtractAsync <NUM, A> (this Try<A> lhs, Try<A> rhs) Source #

where NUM : struct, Num<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> ProductAsync <NUM, A> (this Try<A> lhs, Try<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 TryAsync<A> DivideAsync <NUM, A> (this Try<A> lhs, Try<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?> ToNullableAsync <A> (this Try<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 TryExtensions Source #

Extension methods for the Try monad

Methods

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

Use for pattern-matching the case of the target

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

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

Memoize the computation so that it's only run once

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

If the Try fails, retry amount times

Parameters

type A

Type of bound value

param ma

Try

param amount

Amount of retries

returns

Try

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

Forces evaluation of the lazy try

Parameters

type A

Bound value type

param ma

Computation to evaluate

returns

The Try with the computation executed

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

Test if the Try is in a success state

Parameters

type A

Bound value type

param ma

Computation to evaluate

returns

True if computation has succeeded

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

Test if the Try is in a faulted state

Parameters

type A

Bound value type

param ma

Computation to evaluate

returns

True if computation is faulted

method Unit IfSucc <A> (this Try<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 A IfFail <A> (this Try<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 A IfFail <A> (this Try<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 A IfFail <A> (this Try<A> self, Func<Exception, A> Fail) Source #

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

method ExceptionMatch<A> IfFail <A> (this Try<A> self) Source #

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

Parameters

returns

Fluent exception matcher

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

Invoke a delegate if the Try computation fails

Parameters

type A

Type of bound value

param self

The Try computation

param Fail

The delegate to invoke if the Try computation fails

method R Match <A, R> (this Try<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 R Match <A, R> (this Try<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 Unit Match <A> (this Try<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 Option<A> ToOption <A> (this Try<A> self) Source #

method TryOption<A> ToTryOption <A> (this Try<A> self) Source #

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

method Validation<Exception, A> ToValidation <A> (this Try<A> self) Source #

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

method Either<Exception, A> ToEither <A> (this Try<A> self) Source #

method Either<L, A> ToEither <A, L> (this Try<A> self, Func<Exception, L> Fail) Source #

method EitherUnsafe<Exception, A> ToEitherUnsafe <A> (this Try<A> self) Source #

method EitherUnsafe<L, A> ToEitherUnsafe <A, L> (this Try<A> self, Func<Exception, L> Fail) Source #

method A IfFailThrow <A> (this Try<A> self) Source #

method Try<B> Select <A, B> (this Try<A> self, Func<A, B> f) Source #

Map the bound value from A to B

Parameters

type A

Bound value type

type B

Returned bound value type

param self

This

param f

Mapping function

returns

Mapped Try

method Unit Iter <A> (this Try<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 int Count <A> (this Try<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 bool ForAll <A> (this Try<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 S Fold <A, S> (this Try<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 S BiFold <A, S> (this Try<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 bool Exists <A> (this Try<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 Try<A> Do <A> (this Try<A> ma, Action<A> f) Source #

Impure iteration of the bound value in the structure

Parameters

returns

Returns the original unmodified structure

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

Maps the bound value

Parameters

type A

Type of the bound value

type R

Resulting bound value type

param self

Try computation

param mapper

Delegate to map the bound value

returns

Mapped Try computation

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

Maps the bound value

Parameters

type A

Type of the bound value

type R

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 Try<Func<B, R>> ParMap <A, B, R> (this Try<A> self, Func<A, B, R> func) Source #

Partial application map

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

Partial application map

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

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

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

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

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

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

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

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

method TrySuccContext<A, R> Succ <A, R> (this Try<A> self, Func<A, R> succHandler) Source #

method TrySuccUnitContext<A> Succ <A> (this Try<A> self, Action<A> succHandler) Source #

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

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

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

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

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

where T : IDisposable

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

where T : IDisposable

method int Sum (this Try<int> self) Source #

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

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

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

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

where SEMI : struct, Semigroup<A>

Append 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 Try<A> Add <ARITH, A> (this Try<A> lhs, Try<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 Try<A> Subtract <ARITH, A> (this Try<A> lhs, Try<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 Try<A> Product <ARITH, A> (this Try<A> lhs, Try<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 Try<A> Divide <NUM, A> (this Try<A> lhs, Try<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 A? ToNullable <A> (this Try<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

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

method (IEnumerable<Exception> Fails, IEnumerable<A> Succs) Partition <A> (this IEnumerable<Try<A>> self) Source #

Partitions a list of 'Try' into two lists. All the 'Fail' elements are extracted, in order, to the first component of the output. Similarly the 'Succ' elements are extracted to the second component of the output.

Parameters

type A

Succ

param self

Try list

returns

A tuple containing the an enumerable of Exception and an enumerable of A

method (Seq<Exception> Fails, Seq<A> Succs) Partition <A> (this Seq<Try<A>> self) Source #

Partitions a list of 'Try' into two lists. All the 'Fail' elements are extracted, in order, to the first component of the output. Similarly the 'Succ' elements are extracted to the second component of the output.

Parameters

type A

Succ

param self

Try list

returns

A tuple containing the an enumerable of Exception and an enumerable of A

method Seq<Exception> Fails <A> (this Seq<Try<A>> self) Source #

method Seq<A> Succs <A> (this Seq<Try<A>> self) Source #

method IEnumerable<Exception> Fails <A> (this IEnumerable<Try<A>> self) Source #

method IEnumerable<A> Succs <A> (this IEnumerable<Try<A>> self) Source #

class Prelude Source #

Methods

method Try<A> Try <A> (Func<A> f) Source #

Try constructor function

Parameters

type A

Bound value type

param f

Function to run when invoked

returns

A lifted operation that returns a value of A

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

Try 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 Try<A> TrySucc <A> (A v) Source #

Try 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 Try<A> Try <A> (Exception ex) Source #

Try 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 Try<A> TryFail <A> (Exception ex) Source #

Try 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 Try<A> choice <A> (Try<A> ma, params Try<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 Try<A> choice <A> (Seq<Try<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

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

where SEMI : struct, Semigroup<A>

Append 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 Try<A> add <NUM, A> (Try<A> lhs, Try<A> rhs) Source #

where NUM : struct, Num<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 Try<T> subtract <NUM, T> (Try<T> lhs, Try<T> rhs) Source #

where NUM : struct, Num<T>

Subtract the Try(x) from Try(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 Try<T> product <NUM, T> (Try<T> lhs, Try<T> rhs) Source #

where NUM : struct, Num<T>

Find the product of Try(x) and Try(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 Try<T> divide <NUM, T> (Try<T> lhs, Try<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 Try<B> apply <A, B> (Try<Func<A, B>> fab, Try<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 Try<B> apply <A, B> (Func<A, B> fab, Try<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 Try<C> apply <A, B, C> (Try<Func<A, B, C>> fabc, Try<A> fa, Try<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 Try<C> apply <A, B, C> (Func<A, B, C> fabc, Try<A> fa, Try<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 Try<Func<B, C>> apply <A, B, C> (Try<Func<A, B, C>> fabc, Try<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 Try<Func<B, C>> apply <A, B, C> (Func<A, B, C> fabc, Try<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 Try<Func<B, C>> apply <A, B, C> (Try<Func<A, Func<B, C>>> fabc, Try<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 Try<Func<B, C>> apply <A, B, C> (Func<A, Func<B, C>> fabc, Try<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 Try<B> action <A, B> (Try<A> fa, Try<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 bool isSucc <T> (Try<T> self) Source #

Test if the Try computation is successful

Parameters

type T

Type of the bound value

param self

Try computation to test

returns

True if successful

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

Test if the Try computation fails

Parameters

type T

Type of the bound value

param self

Try computation to test

returns

True if fails

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

Invoke a delegate if the Try returns a value successfully

Parameters

type T

Type of the bound value

param self

Try computation

param Succ

Delegate to invoke if successful

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

Invoke a delegate if the Try fails

Parameters

type T

Type of the bound value

param value

Try computation

param Fail

Delegate to invoke on failure

returns

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

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

Return a default value if the Try fails

Parameters

type T

Type of the bound value

param self

Try computation

param failValue

Default value to use on failure

returns

failValue on failure, the result of the Try otherwise

method ExceptionMatch<T> ifFail <T> (Try<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

Try computation

returns

Fluent exception matcher

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

Invoke a delegate if the Try computation fails

Parameters

type T

Type of bound value

param self

The Try computation

param Fail

The delegate to invoke if the Try computation fails

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

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

Parameters

type T

Type of the bound value

param self

Try computation

returns

Try of Exception

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

Flattens nested Try computations

Parameters

type T

Type of the bound value

param self

Try computation

returns

Flattened Try computation

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

Flattens nested Try computations

Parameters

type T

Type of the bound value

param self

Try computation

returns

Flattened Try computation

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

Flattens nested Try computations

Parameters

type T

Type of the bound value

param self

Try computation

returns

Flattened Try computation

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

Pattern matches the two possible states of the Try 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 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 R match <T, R> (Try<T> self, Func<T, R> Succ, R Fail) Source #

Pattern matches the two possible states of the Try 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 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 Unit match <T> (Try<T> self, Action<T> Succ, Action<Exception> Fail) Source #

Pattern matches the two possible states of the Try computation

Parameters

type T

Type of the bound value

param self

Try computation

param Succ

Delegate to invoke if the Try computation completes successfully

param Fail

Delegate to invoke if the Try computation fails

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

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

Parameters

type T

Type of the bound value

param self

Try computation

param action

Delegate to invoke on successful invocation of the Try computation

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

Parameters

param self

Try to fold

param state

Initial state

param folder

Fold function

returns

Folded state

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

Parameters

param tryDel

Try to fold

param state

Initial state

param Succ

Fold function when Try succeeds

param Fail

Fold function when Try fails

returns

Folded state

method bool forall <T> (Try<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

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 int count <T> (Try<T> 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 bool exists <T> (Try<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 Try<R> map <T, R> (Try<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

Try computation

param mapper

Delegate to map the bound value

returns

Mapped Try computation

method Try<R> bimap <T, R> (Try<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

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 Try<Func<T2, R>> parmap <T1, T2, R> (Try<T1> self, Func<T1, T2, R> func) Source #

Partial application map

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

Partial application map

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

method Try<T> filter <T> (Try<T> self, Func<T, bool> Succ, Func<Exception, bool> Fail) Source #

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

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

method Try<R> bind <T, R> (Try<T> self, Func<T, Try<R>> Succ, Func<Exception, Try<R>> Fail) Source #

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

method Lst<T> toList <T> (Try<T> tryDel) Source #

method Arr<T> toArray <T> (Try<T> tryDel) Source #

method Try<T> tryfun <T> (Func<Try<T>> tryDel) Source #

method (IEnumerable<Exception> Fails, IEnumerable<A> Succs) partition <A> (IEnumerable<Try<A>> self) Source #

Partitions a list of 'Try' into two lists. All the 'Fail' elements are extracted, in order, to the first component of the output. Similarly the 'Succ' elements are extracted to the second component of the output.

Parameters

type A

Succ

param self

Try list

returns

A tuple containing the an enumerable of Exception and an enumerable of A

method (Seq<Exception> Fails, Seq<A> Succs) partition <A> (Seq<Try<A>> self) Source #

Partitions a list of 'Try' into two lists. All the 'Fail' elements are extracted, in order, to the first component of the output. Similarly the 'Succ' elements are extracted to the second component of the output.

Parameters

type A

Succ

param self

Try list

returns

A tuple containing the an enumerable of Exception and an enumerable of A

method Seq<Exception> fails <A> (Seq<Try<A>> self) Source #

method Seq<A> succs <A> (Seq<Try<A>> self) Source #

method IEnumerable<Exception> fails <A> (IEnumerable<Try<A>> self) Source #

method IEnumerable<A> succs <A> (IEnumerable<Try<A>> self) Source #

class TryConfig Source #

Fields

field Action<Exception> ErrorLogger = ex => { } Source #

struct TrySuccContext <T, R> Source #

Methods

method R Fail (Func<Exception, R> failHandler) Source #

method R Fail (R failValue) Source #

struct TrySuccUnitContext <T> Source #

Methods

method Unit Fail (Action<Exception> failHandler) Source #