LanguageExt.Core

LanguageExt.Core Traits Fallible

Contents

class FallibleExtensions Source #

Extensions for higher-kinded structures that have a failure state Error

Parameters

type F

Higher-kinded structure

Methods

method K<F, A> Catch <F, A> ( this K<F, A> fa, Func<Error, bool> Predicate, Func<Error, K<F, A>> Fail) Source #

where F : Fallible<F>

Run the Fallible structure. If in a failed state, test the failure value against the predicate. If, it returns true, run the Fail function with the failure value.

Parameters

type A

Bound value type

param fa

Fallible structure

param Predicate

Predicate to test any failure values

param Fail

Handler when in failed state

returns

Either fa or the result of Fail if fa is in a failed state and the predicate returns true for the failure value

method K<M, A> Catch <M, A> ( this K<M, A> ma, Func<Error, bool> Predicate, Func<Error, K<IO, A>> Fail) Source #

where M : Fallible<M>, Monad<M>

Run the Fallible structure. If in a failed state, test the failure value against the predicate. If, it returns true, run the Fail function with the failure value.

Parameters

type A

Bound value type

param ma

Fallible structure

param Predicate

Predicate to test any failure values

param Fail

Handler when in failed state

returns

Either fa or the result of Fail if fa is in a failed state and the predicate returns true for the failure value

method K<F, A> Catch <F, A> ( this K<F, A> fa, Func<Error, bool> Predicate, Func<Error, Error> Fail) Source #

where F : Fallible<F>

Run the Fallible structure. If in a failed state, test the failure value against the predicate. If, it returns true, run the Fail function with the failure value.

Parameters

type A

Bound value type

param fa

Fallible structure

param Predicate

Predicate to test any failure values

param Fail

Handler when in failed state

returns

Either fa or the result of Fail if fa is in a failed state and the predicate returns true for the failure value

method K<F, A> Catch <F, A> ( this K<F, A> fa, Func<Error, bool> Predicate, Func<Error, A> Fail) Source #

where F : Fallible<F>, Applicative<F>

Run the Fallible structure. If in a failed state, test the failure value against the predicate. If, it returns true, run the Fail function with the failure value.

Parameters

type A

Bound value type

param fa

Fallible structure

param Predicate

Predicate to test any failure values

param Fail

Handler when in failed state

returns

Either fa or the result of Fail if fa is in a failed state and the predicate returns true for the failure value

method K<F, A> Catch <F, A> ( this K<F, A> fa, CatchM<Error, F, A> @catch) Source #

where F : Fallible<F>

Run the Fallible structure. If in a failed state, test the failure value against the catch structure and run its action if a match.

Parameters

type A

Bound value type

param fa

Fallible structure

param @catch

Catch structure created by the @catch functions. Contains the match predicate and action

returns

Either fa or the result of running the catch structure's action if fa is in a failed state and the

method K<F, A> Catch <F, A> ( this K<F, A> fa, Error Match, Func<Error, K<F, A>> Fail) Source #

where F : Fallible<F>

Run the Fallible structure. If in a failed state, test the failure value against the predicate. If, it returns true, run the Fail function with the failure value.

Parameters

type A

Bound value type

param fa

Fallible structure

param Match

Error to match to

param Fail

Handler when in failed state

returns

Either fa or the result of Fail if fa is in a failed state and the predicate returns true for the failure value

method K<M, A> Catch <M, A> ( this K<M, A> ma, Error Match, Func<Error, K<IO, A>> Fail) Source #

where M : Fallible<M>, Monad<M>

Run the Fallible structure. If in a failed state, test the failure value against the predicate. If, it returns true, run the Fail function with the failure value.

Parameters

type A

Bound value type

param ma

Fallible structure

param Match

Error to match to

param Fail

Handler when in failed state

returns

Either fa or the result of Fail if fa is in a failed state and the predicate returns true for the failure value

method K<F, A> Catch <F, A> ( this K<F, A> fa, Error Match, Func<Error, Error> Fail) Source #

where F : Fallible<F>

Run the Fallible structure. If in a failed state, test the failure value against the predicate. If, it returns true, run the Fail function with the failure value.

Parameters

type A

Bound value type

param fa

Fallible structure

param Match

Error to match to

param Fail

Handler when in failed state

returns

Either fa or the result of Fail if fa is in a failed state and the predicate returns true for the failure value

method K<F, A> Catch <F, A> ( this K<F, A> fa, Error Match, Func<Error, A> Fail) Source #

where F : Fallible<F>, Applicative<F>

Run the Fallible structure. If in a failed state, test the failure value against the predicate. If, it returns true, run the Fail function with the failure value.

Parameters

type A

Bound value type

param fa

Fallible structure

param Match

Error to match to

param Fail

Handler when in failed state

returns

Either fa or the result of Fail if fa is in a failed state and the predicate returns true for the failure value

method K<F, A> Catch <F, A> ( this K<F, A> fa, int Code, Func<Error, K<F, A>> Fail) Source #

where F : Fallible<F>

Run the Fallible structure. If in a failed state, test the failure value against the predicate. If, it returns true, run the Fail function with the failure value.

Parameters

type A

Bound value type

param fa

Fallible structure

param Code

Error code to match to

param Fail

Handler when in failed state

returns

Either fa or the result of Fail if fa is in a failed state and the predicate returns true for the failure value

method K<M, A> Catch <M, A> ( this K<M, A> ma, int Code, Func<Error, K<IO, A>> Fail) Source #

where M : Fallible<M>, Monad<M>

Run the Fallible structure. If in a failed state, test the failure value against the predicate. If, it returns true, run the Fail function with the failure value.

Parameters

type A

Bound value type

param ma

Fallible structure

param Code

Error code to match to

param Fail

Handler when in failed state

returns

Either fa or the result of Fail if fa is in a failed state and the predicate returns true for the failure value

method K<F, A> Catch <F, A> ( this K<F, A> fa, int Code, Func<Error, Error> Fail) Source #

where F : Fallible<F>

Run the Fallible structure. If in a failed state, test the failure value against the predicate. If, it returns true, run the Fail function with the failure value.

Parameters

type A

Bound value type

param fa

Fallible structure

param Code

Error code to match to

param Fail

Handler when in failed state

returns

Either fa or the result of Fail if fa is in a failed state and the predicate returns true for the failure value

method K<F, A> Catch <F, A> ( this K<F, A> fa, int Code, Func<Error, A> Fail) Source #

where F : Fallible<F>, Applicative<F>

Run the Fallible structure. If in a failed state, test the failure value against the predicate. If, it returns true, run the Fail function with the failure value.

Parameters

type A

Bound value type

param fa

Fallible structure

param Code

Error code to match to

param Fail

Handler when in failed state

returns

Either fa or the result of Fail if fa is in a failed state and the predicate returns true for the failure value

method K<F, A> Catch <E, F, A> ( this K<F, A> fa, Func<E, K<F, A>> Fail) Source #

where F : Fallible<E, F>

Run the Fallible structure. If in a failed state, test the failure value against the predicate. If, it returns true, run the Fail function with the failure value.

Parameters

type A

Bound value type

param fa

Fallible structure

param Fail

Handler when in failed state

returns

Either fa or the result of Fail if fa is in a failed state and the predicate returns true for the failure value

method K<F, A> Catch <F, A> ( this K<F, A> fa, Func<Error, K<F, A>> Fail) Source #

where F : Fallible<F>

Run the Fallible structure. If in a failed state, test the failure value against the predicate. If, it returns true, run the Fail function with the failure value.

Parameters

type A

Bound value type

param fa

Fallible structure

param Fail

Handler when in failed state

returns

Either fa or the result of Fail if fa is in a failed state and the predicate returns true for the failure value

method K<M, A> Catch <M, A> ( this K<M, A> ma, Func<Error, K<IO, A>> Fail) Source #

where M : Fallible<M>, Monad<M>

Run the Fallible structure. If in a failed state, test the failure value against the predicate. If, it returns true, run the Fail function with the failure value.

Parameters

type A

Bound value type

param ma

Fallible structure

param Fail

Handler when in failed state

returns

Either fa or the result of Fail if fa is in a failed state and the predicate returns true for the failure value

method K<F, A> Catch <F, A> ( this K<F, A> fa, Func<Error, Error> Fail) Source #

where F : Fallible<F>

Run the Fallible structure. If in a failed state, test the failure value against the predicate. If, it returns true, run the Fail function with the failure value.

Parameters

type A

Bound value type

param fa

Fallible structure

param Fail

Handler when in failed state

returns

Either fa or the result of Fail if fa is in a failed state and the predicate returns true for the failure value

method K<F, A> Catch <F, A> ( this K<F, A> fa, Func<Error, A> Fail) Source #

where F : Fallible<F>, Applicative<F>

Run the Fallible structure. If in a failed state, test the failure value against the predicate. If, it returns true, run the Fail function with the failure value.

Parameters

type A

Bound value type

param fa

Fallible structure

param Fail

Handler when in failed state

returns

Either fa or the result of Fail if fa is in a failed state and the predicate returns true for the failure value

method K<F, A> Catch <F, A> (this K<F, A> fa, Fail<Error> fail) Source #

where F : Fallible<F>, Applicative<F>

Run the Fallible structure. If in a failed state, replace the failure value with fail.

Parameters

type A

Bound value type

param fa

Fallible structure

method K<F, A> Catch <F, A> (this K<F, A> fa, Error fail) Source #

where F : Fallible<F>, Applicative<F>

Run the Fallible structure. If in a failed state, replace the failure value with fail.

Parameters

type A

Bound value type

param fa

Fallible structure

method K<F, A> Catch <F, A> (this K<F, A> fa, Pure<A> value) Source #

where F : Fallible<F>, Applicative<F>

Run the Fallible structure. If in a failed state, replace the failure value with the success value and cancelling the failure.

Parameters

type A

Bound value type

param fa

Fallible structure

method K<F, A> Catch <F, A> (this K<F, A> fa, A value) Source #

where F : Fallible<F>, Applicative<F>

Run the Fallible structure. If in a failed state, replace the failure value with the success value and cancelling the failure.

Parameters

type A

Bound value type

param fa

Fallible structure

method K<F, A> Catch <F, A> (this K<F, A> fa, K<F, A> alternative) Source #

where F : Fallible<F>, Applicative<F>

Run the Fallible structure. If in a failed state, replace the failure value with the alternative computation, which may succeed or fail.

Parameters

type A

Bound value type

param fa

Fallible structure

class FallibleExtensionsE Source #

Extensions for higher-kinded structures that have a failure state E

Parameters

type F

Higher-kinded structure

type E

Failure type

Methods

method K<F, A> Catch <E, F, A> ( this K<F, A> fa, Func<E, bool> Predicate, Func<E, K<F, A>> Fail) Source #

where F : Fallible<E, F>

Run the Fallible structure. If in a failed state, test the failure value against the predicate. If, it returns true, run the Fail function with the failure value.

Parameters

type A

Bound value type

param fa

Fallible structure

param Predicate

Predicate to test any failure values

param Fail

Handler when in failed state

returns

Either fa or the result of Fail if fa is in a failed state and the predicate returns true for the failure value

method K<M, A> Catch <E, M, A> ( this K<M, A> ma, Func<E, bool> Predicate, Func<E, K<IO, A>> Fail) Source #

where M : Fallible<E, M>, Monad<M>

Run the Fallible structure. If in a failed state, test the failure value against the predicate. If, it returns true, run the Fail function with the failure value.

Parameters

type A

Bound value type

param ma

Fallible structure

param Predicate

Predicate to test any failure values

param Fail

Handler when in failed state

returns

Either fa or the result of Fail if fa is in a failed state and the predicate returns true for the failure value

method K<F, A> Catch <E, F, A> ( this K<F, A> fa, Func<E, bool> Predicate, Func<E, E> Fail) Source #

where F : Fallible<E, F>

Run the Fallible structure. If in a failed state, test the failure value against the predicate. If, it returns true, run the Fail function with the failure value.

Parameters

type A

Bound value type

param fa

Fallible structure

param Predicate

Predicate to test any failure values

param Fail

Handler when in failed state

returns

Either fa or the result of Fail if fa is in a failed state and the predicate returns true for the failure value

method K<F, A> Catch <E, F, A> ( this K<F, A> fa, Func<E, bool> Predicate, Func<E, A> Fail) Source #

where F : Fallible<E, F>, Applicative<F>

Run the Fallible structure. If in a failed state, test the failure value against the predicate. If, it returns true, run the Fail function with the failure value.

Parameters

type A

Bound value type

param fa

Fallible structure

param Predicate

Predicate to test any failure values

param Fail

Handler when in failed state

returns

Either fa or the result of Fail if fa is in a failed state and the predicate returns true for the failure value

method K<F, A> Catch <E, F, A> ( this K<F, A> fa, CatchM<E, F, A> @catch) Source #

where F : Fallible<E, F>

Run the Fallible structure. If in a failed state, test the failure value against the catch structure and run its action if a match.

Parameters

type A

Bound value type

param fa

Fallible structure

param @catch

Catch structure created by the @catch functions. Contains the match predicate and action

returns

Either fa or the result of running the catch structure's action if fa is in a failed state and the

method K<M, A> Catch <E, M, A> ( this K<M, A> ma, E Match, Func<E, K<IO, A>> Fail) Source #

where M : Fallible<E, M>, Monad<M>

Run the Fallible structure. If in a failed state, test the failure value against the predicate. If, it returns true, run the Fail function with the failure value.

Parameters

type A

Bound value type

param ma

Fallible structure

param Match

Error to match to

param Fail

Handler when in failed state

returns

Either fa or the result of Fail if fa is in a failed state and the predicate returns true for the failure value

method K<F, A> Catch <E, F, A> ( this K<F, A> fa, E Match, Func<E, E> Fail) Source #

where F : Fallible<E, F>

Run the Fallible structure. If in a failed state, test the failure value against the predicate. If, it returns true, run the Fail function with the failure value.

Parameters

type A

Bound value type

param fa

Fallible structure

param Match

Error to match to

param Fail

Handler when in failed state

returns

Either fa or the result of Fail if fa is in a failed state and the predicate returns true for the failure value

method K<F, A> Catch <E, F, A> ( this K<F, A> fa, E Match, Func<E, A> Fail) Source #

where F : Fallible<E, F>, Applicative<F>

Run the Fallible structure. If in a failed state, test the failure value against the predicate. If, it returns true, run the Fail function with the failure value.

Parameters

type A

Bound value type

param fa

Fallible structure

param Match

Error to match to

param Fail

Handler when in failed state

returns

Either fa or the result of Fail if fa is in a failed state and the predicate returns true for the failure value

method K<F, A> Catch <E, F, A> ( this K<F, A> fa, Func<E, K<F, A>> Fail) Source #

where F : Fallible<E, F>

Run the Fallible structure. If in a failed state, test the failure value against the predicate. If, it returns true, run the Fail function with the failure value.

Parameters

type A

Bound value type

param fa

Fallible structure

param Fail

Handler when in failed state

returns

Either fa or the result of Fail if fa is in a failed state and the predicate returns true for the failure value

method K<M, A> Catch <E, M, A> ( this K<M, A> ma, Func<E, K<IO, A>> Fail) Source #

where M : Fallible<E, M>, Monad<M>

Run the Fallible structure. If in a failed state, test the failure value against the predicate. If, it returns true, run the Fail function with the failure value.

Parameters

type A

Bound value type

param ma

Fallible structure

param Fail

Handler when in failed state

returns

Either fa or the result of Fail if fa is in a failed state and the predicate returns true for the failure value

method K<F, A> Catch <E, F, A> ( this K<F, A> fa, Func<E, E> Fail) Source #

where F : Fallible<E, F>

Run the Fallible structure. If in a failed state, test the failure value against the predicate. If, it returns true, run the Fail function with the failure value.

Parameters

type A

Bound value type

param fa

Fallible structure

param Fail

Handler when in failed state

returns

Either fa or the result of Fail if fa is in a failed state and the predicate returns true for the failure value

method K<F, A> Catch <E, F, A> ( this K<F, A> fa, Func<E, A> Fail) Source #

where F : Fallible<E, F>, Applicative<F>

Run the Fallible structure. If in a failed state, test the failure value against the predicate. If, it returns true, run the Fail function with the failure value.

Parameters

type A

Bound value type

param fa

Fallible structure

param Fail

Handler when in failed state

returns

Either fa or the result of Fail if fa is in a failed state and the predicate returns true for the failure value

method K<F, A> Catch <E, F, A> (this K<F, A> fa, Fail<E> fail) Source #

where F : Fallible<E, F>, Applicative<F>

Run the Fallible structure. If in a failed state, replace the failure value with fail.

Parameters

type A

Bound value type

param fa

Fallible structure

method K<F, A> Catch <E, F, A> (this K<F, A> fa, E fail) Source #

where F : Fallible<E, F>, Applicative<F>

Run the Fallible structure. If in a failed state, replace the failure value with fail.

Parameters

type A

Bound value type

param fa

Fallible structure

method K<F, A> Catch <E, F, A> (this K<F, A> fa, Pure<A> value) Source #

where F : Fallible<E, F>, Applicative<F>

Run the Fallible structure. If in a failed state, replace the failure value with the success value and cancelling the failure.

Parameters

type A

Bound value type

param fa

Fallible structure

method K<F, A> Catch <E, F, A> (this K<F, A> fa, A value) Source #

where F : Fallible<E, F>, Applicative<F>

Run the Fallible structure. If in a failed state, replace the failure value with the success value and cancelling the failure.

Parameters

type A

Bound value type

param fa

Fallible structure

method K<F, A> Catch <E, F, A> (this K<F, A> fa, K<F, A> alternative) Source #

where F : Fallible<E, F>, Applicative<F>

Run the Fallible structure. If in a failed state, replace the failure value with the alternative computation, which may succeed or fail.

Parameters

type A

Bound value type

param fa

Fallible structure

interface Fallible <FA, F, E, A> Source #

where FA : Fallible<FA, F, E, A>
where F : Fallible<E, F>, Applicative<F>

Derive your concrete types from this interface to acquire to common set of operators that will make working with the generic Fallible trait more elegant.

It isn't a requirement to implement this interface for Fallible to work, but it guides the implementor. It is optional!

Primarily makes @catch work nicely, but is generally benefical.

Parameters

type FA

'Self' type, for example Either<L, R>

type F

Trait implementation, for example Either<L>

type E

Failure type, for example L

type A

Bound value type, for example R

Operators

operator | (FA lhs, FA rhs) Source #

operator | (K<F, A> lhs, FA rhs) Source #

operator | (FA lhs, K<F, A> rhs) Source #

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

operator | (FA lhs, Fail<E> rhs) Source #

operator | (FA lhs, CatchM<E, F, A> rhs) Source #

class Fallible Source #

Module for higher-kinded structures that have a failure state E

Parameters

type F

Higher-kinded structure

type E

Failure type

Methods

method K<F, A> fail <E, F, A> (E error) Source #

where F : Fallible<E, F>

Raise a failure state in the Fallible structure F

Parameters

type F

Fallible trait

type E

Error type

type A

Bound value type

param error

Error to raise

returns

method K<F, A> error <F, A> (Error error) Source #

where F : Fallible<Error, F>

Raise a failure state in the Fallible structure F

Parameters

type F

Fallible trait

type A

Bound value type

param error

Error to raise

returns

method K<F, Unit> fail <E, F> (E error) Source #

where F : Fallible<E, F>

Raise a failure state in the Fallible structure F

Parameters

type F

Fallible trait

type E

Error type

type A

Bound value type

param error

Error to raise

returns

method K<F, Unit> error <F> (Error error) Source #

where F : Fallible<Error, F>

Raise a failure state in the Fallible structure F

Parameters

type F

Fallible trait

type E

Error type

type A

Bound value type

param error

Error to raise

returns

interface Fallible <E, F> Source #

Trait for higher-kinded structures that have a failure state E

Parameters

type E

Failure type

type F

Higher-kinded structure

Methods

method K<F, A> Fail <A> (E error) Source #

Raise a failure state in the Fallible structure F

Parameters

type A

Bound value type

param error

Error value

returns

method K<F, A> Catch <A> ( K<F, A> fa, Func<E, bool> Predicate, Func<E, K<F, A>> Fail) Source #

Run the Fallible structure. If in a failed state, test the failure value against the predicate. If, it returns true, run the Fail function with the failure value.

Parameters

type A

Bound value type

param fa

Fallible structure

param Predicate

Predicate to test any failure values

param Fail

Handler when in failed state

returns

Either fa or the result of Fail if fa is in a failed state and the predicate returns true for the failure value

interface Fallible <F> Source #

Trait for higher-kinded structures that have a failure state E

Parameters

type F

Higher-kinded structure

type E

Failure type