The Fin
monad supports either an Error
or an A
(success) value. It is functionally exactly the same as Either<Error, A>
, it is a
convenience type to avoid the generics pain of Either
.
To construct a Fin
:
Fin<int> ma = Pure(123);
Fin<int> mb = Fail(Error.New("Error!"));
- Fin <A>
- Succ (A value)
- Fail (Error error)
- Fail (string error)
- IsSucc
- IsFail
- Match <B> (Func<A, B> Succ, Func<Error, B> Fail)
- FailSpan ()
- SuccSpan ()
- CompareTo <OrdA> (Fin<A> other)
- Equals <EqA> (Fin<A> other)
- Equals (Fin<A>? other)
- Equals (object? other)
- GetHashCode <HashA> ()
- GetHashCode ()
- Map <B> (Func<A, B> f)
- MapFail (Func<Error, Error> f)
- BiMap <B> (Func<A, B> Succ, Func<Error, Error> Fail)
- Bind <B> (Func<A, Fin<B>> f)
- BiBind <B> (Func<A, Fin<B>> Succ, Func<Error, Fin<B>> Fail)
- BindFail (Func<Error, Fin<A>> Fail)
- Empty
- + (Fin<A> lhs, Fin<A> rhs)
- + (K<Fin, A> lhs, Fin<A> rhs)
- + (Fin<A> lhs, K<Fin, A> rhs)
- + (Fin<A> ma, Pure<A> mb)
- + (Fin<A> ma, Fail<Error> mb)
- + (Fin<A> ma, Fail<Exception> mb)
- | (Fin<A> lhs, Fin<A> rhs)
- | (K<Fin, A> lhs, Fin<A> rhs)
- | (Fin<A> lhs, K<Fin, A> rhs)
- | (Fin<A> ma, Pure<A> mb)
- | (Fin<A> ma, Fail<Error> mb)
- | (Fin<A> ma, Fail<Exception> mb)
- | (Fin<A> ma, CatchM<Error, Fin, A> mb)
- true (Fin<A> ma)
- false (Fin<A> ma)
- == (Fin<A> ma, Fin<A> mb)
- != (Fin<A> ma, Fin<A> mb)
- < (Fin<A> lhs, A rhs)
- <= (Fin<A> lhs, A rhs)
- > (Fin<A> lhs, A rhs)
- >= (Fin<A> lhs, A rhs)
- < (A lhs, Fin<A> rhs)
- <= (A lhs, Fin<A> rhs)
- > (A lhs, Fin<A>rhs)
- >= (A lhs, Fin<A> rhs)
- < (Fin<A> lhs, Fin<A> rhs)
- <= (Fin<A> lhs, Fin<A> rhs)
- > (Fin<A> lhs, Fin<A> rhs)
- >= (Fin<A> lhs, Fin<A> rhs)
- == (Fin<A> lhs, Error rhs)
- == (Fin<A> lhs, A rhs)
- == (A lhs, Fin<A> rhs)
- == (Error lhs, Fin<A> rhs)
- != (Fin<A> lhs, Error rhs)
- != (Error lhs, Fin<A> rhs)
- != (Fin<A> lhs, A rhs)
- != (A lhs, Fin<A> rhs)
- CompareTo (Fin<A>? other)
- GetEnumerator ()
- CompareTo (object? obj)
- Match (Action<A> Succ, Action<Error> Fail)
- IfFail (Func<Error, A> Fail)
- IfFail (A alternative)
- IfFail (Action<Error> Fail)
- IfSucc (Action<A> Succ)
- Iter (Action<A> Succ)
- Fold <S> (S state, Func<S, A, S> f)
- BiFold <S> (in S state, Func<S, A, S> Succ, Func<S, Error, S> Fail)
- Exists (Func<A, bool> f)
- ForAll (Func<A, bool> f)
- Traverse <F, B> (Func<A, K<F, B>> f)
- TraverseM <M, B> (Func<A, K<M, B>> f)
- Select <B> (Func<A, B> f)
- Bind <B> (Func<A, K<Fin, B>> f)
- Bind <B> (Func<A, Pure<B>> f)
- Bind (Func<A, Fail<Error>> f)
- SelectMany <B, C> (Func<A, Fin<B>> bind, Func<A, B, C> project)
- SelectMany <B, C> (Func<A, K<Fin, B>> bind, Func<A, B, C> project)
- SelectMany <B, C> (Func<A, Pure<B>> bind, Func<A, B, C> project)
- SelectMany (Func<A, Fail<Error>> bind, Func<A, Error, Unit> project)
- ToList ()
- ToSeq ()
- ToArray ()
- ToOption ()
- ToStream <M> ()
- FailToStream <M> ()
- ToEither ()
- ToValidation ()
- ToEff ()
- ThrowIfFail ()
- FinExtensions
- As <A> (this K<Fin, A> ma)
- ToFin <A> (this Either<Error, A> ma)
- Flatten <R> (this Fin<Fin<R>> ma)
- Plus <NUM, R> (this Fin<R> x, Fin<R> y)
- Subtract <NUM, R> (this Fin<R> x, Fin<R> y)
- Product <NUM, R> (this Fin<R> x, Fin<R> y)
- Divide <NUM, R> (this Fin<R> x, Fin<R> y)
- Succs <A> (this IEnumerable<Fin<A>> xs)
- Succs <A> (this Seq<Fin<A>> xs)
- Fails <A> (this IEnumerable<Fin<A>> xs)
- Fails <A> (this Seq<Fin<A>> xs)
- Partition <A> (this IEnumerable<Fin<A>> xs)
- Partition <A> (this Seq<Fin<A>> xs)
- FinExtensions
- Map <A, B> (this Func<A, B> f, K<Fin, A> ma)
- Map <A, B> (this Func<A, B> f, Fin<A> ma)
- Action <A, B> (this Fin<A> ma, K<Fin, B> mb)
- Action <A, B> (this K<Fin, A> ma, K<Fin, B> mb)
- Apply <A, B> (this Fin<Func<A, B>> mf, K<Fin, A> ma)
- Apply <A, B> (this K<Fin, Func<A, B>> mf, K<Fin, A> ma)
- Fin
- Fail <A>
- Error
- IsSucc
- IsFail
- Match <B> (Func<A, B> Succ, Func<Error, B> Fail)
- ToString ()
- GetHashCode <HashA> ()
- FailSpan ()
- SuccSpan ()
- CompareTo <OrdA> (Fin<A> other)
- Equals <EqA> (Fin<A> other)
- Map <B> (Func<A, B> f)
- MapFail (Func<Error, Error> f)
- BiMap <B> (Func<A, B> Succ, Func<Error, Error> Fail)
- Bind <B> (Func<A, Fin<B>> f)
- BiBind <B> ( Func<A, Fin<B>> Succ, Func<Error, Fin<B>> Fail)
- Deconstruct (out Error value)
- FinGuardExtensions
- ToFin (this Guard<Error, Unit> ma)
- SelectMany <B> (this Guard<Error, Unit> ma, Func<Unit, Fin<B>> f)
- SelectMany <B, C> (this Guard<Error, Unit> ma, Func<Unit, Fin<B>> bind, Func<Unit, B, C> project)
- SelectMany <A> (this Fin<A> ma, Func<A, Guard<Error, Unit>> f)
- SelectMany <A, C> (this Fin<A> ma, Func<A, Guard<Error, Unit>> bind, Func<A, Unit, C> project)
- Fin
- Prelude
- flatten <R> (Fin<Fin<R>> ma)
- plus <NUM, R> (Fin<R> x, Fin<R> y)
- subtract <NUM, R> (Fin<R> x, Fin<R> y)
- product <NUM, R> (Fin<R> x, Fin<R> y)
- divide <NUM, R> (Fin<R> x, Fin<R> y)
- isSucc <A> (Fin<A> value)
- isFail <A> (Fin<A> value)
- FinSucc <A> (A value)
- FinFail <A> (Error value)
- ifFail <A> (Fin<A> ma, Func<Error, A> Fail)
- ifFail <A> (Fin<A> ma, A alternative)
- ifFail <A> (Fin<A> ma, Action<Error> Left)
- ifSucc <A> (Fin<A> ma, Action<A> Succ)
- match <A, B> (Fin<A> ma, Func<A, B> Succ, Func<Error, B> Fail)
- match <A> (Fin<A> ma, Action<A> Succ, Action<Error> Fail)
- bifold <S, A> (Fin<A> ma, S state, Func<S, A, S> Right, Func<S, Error, S> Left)
- forall <A> (Fin<A> ma, Func<A, bool> pred)
- exists <A> (Fin<A> ma, Func<A, bool> pred)
- map <A, B> (Fin<A> ma, Func<A, B> f)
- bimap <A, B> (Fin<A> ma, Func<A, B> Succ, Func<Error, Error> Fail)
- bind <A, B> (Fin<A> ma, Func<A, Fin<B>> f)
- Match <A, B> (this IEnumerable<Fin<A>> xs, Func<A, B> Succ, Func<Error, B> Fail )
- match <A, B> (IEnumerable<Fin<A>> xs, Func<A, B> Succ, Func<Error, B> Fail)
- succs <A> (IEnumerable<Fin<A>> xs)
- succs <A> (Seq<Fin<A>> xs)
- fails <A> (IEnumerable<Fin<A>> xs)
- fails <A> (Seq<Fin<A>> xs)
- partition <A> (IEnumerable<Fin<A>> xs)
- partition <A> (Seq<Fin<A>> xs)
- Prelude
- map <A, B> (Func<A, B> f, K<Fin, A> ma)
- action <A, B> (K<Fin, A> ma, K<Fin, B> mb)
- apply <A, B> (K<Fin, Func<A, B>> mf, K<Fin, A> ma)
- Fin
- Succ <A>
- Value
- IsSucc
- IsFail
- Match <B> (Func<A, B> Succ, Func<Error, B> Fail)
- ToString ()
- GetHashCode <HashA> ()
- FailSpan ()
- SuccSpan ()
- CompareTo <OrdA> (Fin<A>? other)
- Equals <EqA> (Fin<A> other)
- Map <B> (Func<A, B> Succ)
- MapFail (Func<Error, Error> f)
- BiMap <B> (Func<A, B> Succ, Func<Error, Error> Fail)
- Bind <B> (Func<A, Fin<B>> f)
- BiBind <B> ( Func<A, Fin<B>> Succ, Func<Error, Fin<B>> Fail)
- Deconstruct (out A value)
Equivalent of Either<Error, A>
Called Fin
because it is expected to be used as the concrete result of a computation
method B Match <B> (Func<A, B> Succ, Func<Error, B> Fail) Source #
Invokes the Succ or Fail function depending on the state of the structure
type | B | Return type |
param | Succ | Function to invoke if in a Succ state |
param | Fail | Function to invoke if in a Fail state |
returns | The return value of the invoked function |
method int CompareTo <OrdA> (Fin<A> other) Source #
Compare this structure to another to find its relative ordering
method int GetHashCode () Source #
method Fin<B> Map <B> (Func<A, B> f) Source #
Maps the value in the structure
param | f | Map function |
returns | Mapped structure |
method Fin<A> MapFail (Func<Error, Error> f) Source #
Maps the value in the structure
param | f | Map function |
returns | Mapped structure |
method Fin<B> BiMap <B> (Func<A, B> Succ, Func<Error, Error> Fail) Source #
Bi-maps the structure
returns | Mapped Either |
method Fin<B> Bind <B> (Func<A, Fin<B>> f) Source #
Monadic bind
type | B | Resulting bound value |
param | f | Bind function |
returns | Bound structure |
method Fin<B> BiBind <B> (Func<A, Fin<B>> Succ, Func<Error, Fin<B>> Fail) Source #
Bi-bind. Allows mapping of both monad states
method IEnumerator<A> GetEnumerator () Source #
method K<F, Fin<B>> Traverse <F, B> (Func<A, K<F, B>> f) Source #
Map each element of a structure to an action, evaluate these actions from left to right, and collect the results.
type | F | Applicative functor trait |
type | B | Bound value (output) |
param | f | |
param | ta | Traversable structure |
method K<M, Fin<B>> TraverseM <M, B> (Func<A, K<M, B>> f) Source #
Map each element of a structure to an action, evaluate these actions from left to right, and collect the results.
type | M | Monad trait |
type | B | Bound value (output) |
param | f | |
param | ta | Traversable structure |
method Fin<C> SelectMany <B, C> (Func<A, Fin<B>> bind, Func<A, B, C> project) Source #
method Fin<C> SelectMany <B, C> (Func<A, K<Fin, B>> bind, Func<A, B, C> project) Source #
method Fin<C> SelectMany <B, C> (Func<A, Pure<B>> bind, Func<A, B, C> project) Source #
method Fin<Unit> SelectMany (Func<A, Fail<Error>> bind, Func<A, Error, Unit> project) Source #
method Validation<Error, A> ToValidation () Source #
method A ThrowIfFail () Source #
operator < (Fin<A> lhs, A rhs) Source #
Comparison operator
param | lhs | The left hand side of the operation |
param | rhs | The right hand side of the operation |
returns | True if lhs < rhs |
operator <= (Fin<A> lhs, A rhs) Source #
Comparison operator
param | lhs | The left hand side of the operation |
param | rhs | The right hand side of the operation |
returns | True if lhs < rhs |
operator > (Fin<A> lhs, A rhs) Source #
Comparison operator
param | lhs | The left hand side of the operation |
param | rhs | The right hand side of the operation |
returns | True if lhs < rhs |
operator >= (Fin<A> lhs, A rhs) Source #
Comparison operator
param | lhs | The left hand side of the operation |
param | rhs | The right hand side of the operation |
returns | True if lhs < rhs |
operator < (A lhs, Fin<A> rhs) Source #
Comparison operator
param | lhs | The left hand side of the operation |
param | rhs | The right hand side of the operation |
returns | True if lhs < rhs |
operator <= (A lhs, Fin<A> rhs) Source #
Comparison operator
param | lhs | The left hand side of the operation |
param | rhs | The right hand side of the operation |
returns | True if lhs < rhs |
operator > (A lhs, Fin<A>rhs) Source #
Comparison operator
param | lhs | The left hand side of the operation |
param | rhs | The right hand side of the operation |
returns | True if lhs < rhs |
operator >= (A lhs, Fin<A> rhs) Source #
Comparison operator
param | lhs | The left hand side of the operation |
param | rhs | The right hand side of the operation |
returns | True if lhs < rhs |
operator < (Fin<A> lhs, Fin<A> rhs) Source #
Comparison operator
param | lhs | The left hand side of the operation |
param | rhs | The right hand side of the operation |
returns | True if lhs < rhs |
operator <= (Fin<A> lhs, Fin<A> rhs) Source #
Comparison operator
param | lhs | The left hand side of the operation |
param | rhs | The right hand side of the operation |
returns | True if lhs <= rhs |
operator > (Fin<A> lhs, Fin<A> rhs) Source #
Comparison operator
param | lhs | The left hand side of the operation |
param | rhs | The right hand side of the operation |
returns | True if lhs > rhs |
class FinExtensions Source #
Extension methods for Fin
method Fin<A> ToFin <A> (this Either<Error, A> ma) Source #
Natural transformation from Either
to Fin
method Fin<R> Plus <NUM, R> (this Fin<R> x, Fin<R> y) Source #
Add the bound values of x and y, uses an Add trait to provide the add operation for type A. For example x.Add<TInteger,int>(y)
type | NUM | Num of A |
type | A | Bound value type |
param | x | Left hand side of the operation |
param | y | Right hand side of the operation |
returns | Fin with y added to x |
method Fin<R> Subtract <NUM, R> (this Fin<R> x, Fin<R> y) Source #
Find the subtract between the two bound values of x and y, uses a Subtract trait to provide the subtract operation for type A. For example x.Subtract<TInteger,int>(y)
type | NUM | Num of A |
type | A | Bound value type |
param | x | Left hand side of the operation |
param | y | Right hand side of the operation |
returns | Fin with the subtract between x and y |
method Fin<R> Product <NUM, R> (this Fin<R> x, Fin<R> y) Source #
Find the product between the two bound values of x and y, uses a Product trait to provide the product operation for type A. For example x.Product<TInteger,int>(y)
type | NUM | Num of A |
type | A | Bound value type |
param | x | Left hand side of the operation |
param | y | Right hand side of the operation |
returns | Fin with the product of x and y |
method Fin<R> Divide <NUM, R> (this Fin<R> x, Fin<R> y) Source #
Divide the two bound values of x and y, uses a Divide trait to provide the divide operation for type A. For example x.Divide<TDouble,double>(y)
type | NUM | Num of A |
type | A | Bound value type |
param | x | Left hand side of the operation |
param | y | Right hand side of the operation |
returns | Fin x / y |
method IEnumerable<A> Succs <A> (this IEnumerable<Fin<A>> xs) Source #
Extracts from a list of Fins all the Succ elements.
type | A | Bound value type |
param | xs | Sequence of Fins |
returns | An enumerable of A |
method Seq<A> Succs <A> (this Seq<Fin<A>> xs) Source #
Extracts from a list of Fins all the Succ elements.
type | A | Bound value type |
param | xs | Sequence of Fins |
returns | An enumerable of A |
method IEnumerable<Error> Fails <A> (this IEnumerable<Fin<A>> xs) Source #
Extracts from a list of Fins all the Fail elements.
Bottom values are dropped
type | A | Bound value type |
param | xs | Sequence of Fins |
returns | An enumerable of Errors |
method Seq<Error> Fails <A> (this Seq<Fin<A>> xs) Source #
Extracts from a list of Fins all the Fail elements.
Bottom values are dropped
type | A | Bound value type |
param | xs | Sequence of Fins |
returns | An enumerable of Errors |
method (IEnumerable<Error> Fails, IEnumerable<A> Succs) Partition <A> (this IEnumerable<Fin<A>> xs) Source #
Partitions a list of 'Fin' 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.
type | A | Bound value type |
param | xs | Fin list |
returns | A tuple containing |
method (Seq<Error> Fails, Seq<A> Succs) Partition <A> (this Seq<Fin<A>> xs) Source #
Partitions a list of 'Fin' 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.
type | A | Bound value type |
param | xs | Fin list |
returns | A tuple containing |
class FinExtensions Source #
method Fin<B> Map <A, B> (this Func<A, B> f, K<Fin, A> ma) Source #
Functor map operation
Unwraps the value within the functor, passes it to the map function f
provided, and
then takes the mapped value and wraps it back up into a new functor.
param | ma | Functor to map |
param | f | Mapping function |
returns | Mapped functor |
method Fin<B> Map <A, B> (this Func<A, B> f, Fin<A> ma) Source #
Functor map operation
Unwraps the value within the functor, passes it to the map function f
provided, and
then takes the mapped value and wraps it back up into a new functor.
param | ma | Functor to map |
param | f | Mapping function |
returns | Mapped functor |
method Fin<B> Action <A, B> (this Fin<A> ma, K<Fin, B> mb) Source #
Applicative action: runs the first applicative, ignores the result, and returns the second applicative
method Fin<B> Action <A, B> (this K<Fin, A> ma, K<Fin, B> mb) Source #
Applicative action: runs the first applicative, ignores the result, and returns the second applicative
method Fin<B> Apply <A, B> (this Fin<Func<A, B>> mf, K<Fin, A> ma) Source #
Applicative functor apply operation
Unwraps the value within the ma
applicative-functor, passes it to the unwrapped function(s) within mf
, and
then takes the resulting value and wraps it back up into a new applicative-functor.
param | ma | Value(s) applicative functor |
param | mf | Mapping function(s) |
returns | Mapped applicative functor |
method Fin<B> Apply <A, B> (this K<Fin, Func<A, B>> mf, K<Fin, A> ma) Source #
Applicative functor apply operation
Unwraps the value within the ma
applicative-functor, passes it to the unwrapped function(s) within mf
, and
then takes the resulting value and wraps it back up into a new applicative-functor.
param | ma | Value(s) applicative functor |
param | mf | Mapping function(s) |
returns | Mapped applicative functor |
method B Match <B> (Func<A, B> Succ, Func<Error, B> Fail) Source #
Invokes the Succ or Fail function depending on the state of the structure
type | B | Return type |
param | Succ | Function to invoke if in a Succ state |
param | Fail | Function to invoke if in a Fail state |
returns | The return value of the invoked function |
method int GetHashCode <HashA> () Source #
method int CompareTo <OrdA> (Fin<A> other) Source #
Compare this structure to another to find its relative ordering
method Fin<B> Map <B> (Func<A, B> f) Source #
Maps the value in the structure
param | f | Map function |
returns | Mapped structure |
method Fin<A> MapFail (Func<Error, Error> f) Source #
Maps the value in the structure
param | f | Map function |
returns | Mapped structure |
method Fin<B> BiMap <B> (Func<A, B> Succ, Func<Error, Error> Fail) Source #
Bi-maps the structure
returns | Mapped Either |
method Fin<B> Bind <B> (Func<A, Fin<B>> f) Source #
Monadic bind
type | B | Resulting bound value |
param | f | Bind function |
returns | Bound structure |
method Fin<B> BiBind <B> ( Func<A, Fin<B>> Succ, Func<Error, Fin<B>> Fail) Source #
Bi-bind. Allows mapping of both monad states
method void Deconstruct (out Error value) Source #
class FinGuardExtensions Source #
method Fin<B> SelectMany <B> (this Guard<Error, Unit> ma, Func<Unit, Fin<B>> f) Source #
method Fin<C> SelectMany <B, C> (this Guard<Error, Unit> ma, Func<Unit, Fin<B>> bind, Func<Unit, B, C> project) Source #
method Fin<Unit> SelectMany <A> (this Fin<A> ma, Func<A, Guard<Error, Unit>> f) Source #
method Fin<C> SelectMany <A, C> (this Fin<A> ma, Func<A, Guard<Error, Unit>> bind, Func<A, Unit, C> project) Source #
method Fin<R> plus <NUM, R> (Fin<R> x, Fin<R> y) Source #
Add the bound values of x and y, uses an Add trait to provide the add operation for type A. For example x.Add<TInteger,int>(y)
type | NUM | Num of A |
type | A | Bound value type |
param | x | Left hand side of the operation |
param | y | Right hand side of the operation |
returns | Fin with y added to x |
method Fin<R> subtract <NUM, R> (Fin<R> x, Fin<R> y) Source #
Find the subtract between the two bound values of x and y, uses a Subtract trait to provide the subtract operation for type A. For example x.Subtract<TInteger,int>(y)
type | NUM | Num of A |
type | A | Bound value type |
param | x | Left hand side of the operation |
param | y | Right hand side of the operation |
returns | Fin with the subtract between x and y |
method Fin<R> product <NUM, R> (Fin<R> x, Fin<R> y) Source #
Find the product between the two bound values of x and y, uses a Product trait to provide the product operation for type A. For example x.Product<TInteger,int>(y)
type | NUM | Num of A |
type | A | Bound value type |
param | x | Left hand side of the operation |
param | y | Right hand side of the operation |
returns | Fin with the product of x and y |
method Fin<R> divide <NUM, R> (Fin<R> x, Fin<R> y) Source #
Divide the two bound values of x and y, uses a Divide trait to provide the divide operation for type A. For example x.Divide<TDouble,double>(y)
type | NUM | Num of A |
type | A | Bound value type |
param | x | Left hand side of the operation |
param | y | Right hand side of the operation |
returns | Fin x / y |
method bool isSucc <A> (Fin<A> value) Source #
Returns the state of the Fin provided
type | A | Bound value type |
param | value | Either to check |
returns | True if the Fin is in a Succ state |
method bool isFail <A> (Fin<A> value) Source #
Returns the state of the Fin provided
type | A | Bound value type |
param | value | Either to check |
returns | True if the Fin is in an Error state |
method Fin<A> FinSucc <A> (A value) Source #
Fin constructor Constructs a Fin in a success state
type | A | Bound value type |
param | value | Success value |
returns | A new Fin instance |
method Fin<A> FinFail <A> (Error value) Source #
Fin constructor Constructs a Fin in a failure state
type | A | Bound value type |
param | value | Failure value |
returns | A new Fin instance |
method A ifFail <A> (Fin<A> ma, Func<Error, A> Fail) Source #
Executes the Fail function if the Fin is in a failure state. Returns the bound value if the Fin is in a success state.
type | A | Bound value type |
param | Fail | Function to generate a Fail value if in the failure state |
returns | Returns an unwrapped bound value |
method A ifFail <A> (Fin<A> ma, A alternative) Source #
Returns the alternative if the Fin is in a failure state. Returns the bound value if the Fin is in a success state.
type | A | Bound value type |
param | alternative | Value to return if in the failure state |
returns | Returns an unwrapped value |
method Unit ifFail <A> (Fin<A> ma, Action<Error> Left) Source #
Executes the Fail action if the Fin is in a failure state.
param | Fail | Function to generate a value if in the failure state |
returns | Returns an unwrapped value |
method Unit ifSucc <A> (Fin<A> ma, Action<A> Succ) Source #
Invokes the Succ action if the Fin is in a success state, otherwise does nothing
param | Succ | Action to invoke |
returns | Unit |
method B match <A, B> (Fin<A> ma, Func<A, B> Succ, Func<Error, B> Fail) Source #
Invokes the Succ or Fail function depending on the state of the Fin provided
type | A | Bound value type |
type | B | Return type |
param | ma | Fin to match |
param | Succ | Function to invoke if in a Succ state |
param | Fail | Function to invoke if in a Fail state |
returns | The return value of the invoked function |
method Unit match <A> (Fin<A> ma, Action<A> Succ, Action<Error> Fail) Source #
Invokes the Succ or Fail action depending on the state of the Fin provided
type | A | Bound value type |
param | ma | Fin to match |
param | Succ | Action to invoke if in a Succ state |
param | Fail | Action to invoke if in a Fail state |
returns | Unit |
method S bifold <S, A> (Fin<A> ma, S state, Func<S, A, S> Right, Func<S, Error, S> Left) Source #
Fin types are like lists of 0 or 1 items, and therefore follow the same rules when folding.
In the case of lists, 'Fold', when applied to a binary operator, a starting value(typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:
type | S | Aggregate state type |
type | A | Bound value type |
param | state | Initial state |
param | Right | Folder function, applied if Either is in a Succ state |
param | Left | Folder function, applied if Either is in a Fail state |
returns | The aggregate state |
method bool forall <A> (Fin<A> ma, Func<A, bool> pred) Source #
Invokes a predicate on the value of the Fin if it's in the Succ state
type | A | Bound value type |
param | ma | Fin to extract the value from |
param | pred | Predicate |
returns | True if the Fin is in a Fail state. True if the Fin is in a Right state and the predicate returns True. False otherwise. |
method bool exists <A> (Fin<A> ma, Func<A, bool> pred) Source #
Invokes a predicate on the value of the Fin if it's in the Succ state
type | A | Bound value type |
param | ma | Fin to extract the value from |
param | pred | Predicate |
returns | True if the Fin is in a Succ state and the predicate returns True. False otherwise. |
method Fin<B> map <A, B> (Fin<A> ma, Func<A, B> f) Source #
Maps the value in the Either if it's in a Right state
type | A | Bound value type |
type | B | Mapped bound value type |
param | ma | Either to map |
param | f | Map function |
returns | Mapped Either |
method Fin<B> bimap <A, B> (Fin<A> ma, Func<A, B> Succ, Func<Error, Error> Fail) Source #
Bi-maps the value in the Fin
type | A | Bound value type |
type | B | Mapped value type if in Succ state |
param | ma | Fin to map |
param | Succ | Success state map function |
param | Fail | Failure state map function |
returns | Bi-mapped Fin |
method Fin<B> bind <A, B> (Fin<A> ma, Func<A, Fin<B>> f) Source #
Monadic bind function https://en.wikipedia.org/wiki/Monad_(functional_programming)
method IEnumerable<B> Match <A, B> (this IEnumerable<Fin<A>> xs, Func<A, B> Succ, Func<Error, B> Fail ) Source #
Match over a sequence of Fins
type | A | Bound values type |
type | B | Mapped bound values type |
param | xs | Sequence to match over |
param | Succ | Success state match function |
param | Fail | Failure state match function |
returns | Sequence of mapped values |
method IEnumerable<B> match <A, B> (IEnumerable<Fin<A>> xs, Func<A, B> Succ, Func<Error, B> Fail) Source #
Match over a sequence of Fins
Bottom values are dropped
type | A | Bound values type |
type | B | Mapped bound values type |
param | xs | Sequence to match over |
param | Succ | Success state match function |
param | Fail | Failure state match function |
returns | Sequence of mapped values |
method IEnumerable<A> succs <A> (IEnumerable<Fin<A>> xs) Source #
Extracts from a list of Fins all the Succ elements.
type | A | Bound value type |
param | xs | Sequence of Fins |
returns | An enumerable of A |
method Seq<A> succs <A> (Seq<Fin<A>> xs) Source #
Extracts from a list of Fins all the Succ elements.
type | A | Bound value type |
param | xs | Sequence of Fins |
returns | An enumerable of A |
method IEnumerable<Error> fails <A> (IEnumerable<Fin<A>> xs) Source #
Extracts from a list of Fins all the Fail elements.
Bottom values are dropped
type | A | Bound value type |
param | xs | Sequence of Fins |
returns | An enumerable of Errors |
method Seq<Error> fails <A> (Seq<Fin<A>> xs) Source #
Extracts from a list of Fins all the Fail elements.
Bottom values are dropped
type | A | Bound value type |
param | xs | Sequence of Fins |
returns | An enumerable of Errors |
method (IEnumerable<Error> Fails, IEnumerable<A> Succs) partition <A> (IEnumerable<Fin<A>> xs) Source #
Partitions a list of 'Fin' 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.
Bottom values are dropped
type | A | Bound value type |
param | xs | Fin list |
returns | A tuple containing the an enumerable of Erorr and an enumerable of Succ |
method (Seq<Error> Fails, Seq<A> Succs) partition <A> (Seq<Fin<A>> xs) Source #
Partitions a list of 'Fin' 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.
Bottom values are dropped
type | A | Bound value type |
param | xs | Fin list |
returns | A tuple containing the an enumerable of Erorr and an enumerable of Succ |
method Fin<B> map <A, B> (Func<A, B> f, K<Fin, A> ma) Source #
Functor map operation
Unwraps the value within the functor, passes it to the map function f
provided, and
then takes the mapped value and wraps it back up into a new functor.
param | ma | Functor to map |
param | f | Mapping function |
returns | Mapped functor |
method Fin<B> action <A, B> (K<Fin, A> ma, K<Fin, B> mb) Source #
Applicative action: runs the first applicative, ignores the result, and returns the second applicative
method Fin<B> apply <A, B> (K<Fin, Func<A, B>> mf, K<Fin, A> ma) Source #
Applicative functor apply operation
Unwraps the value within the ma
applicative-functor, passes it to the unwrapped function(s) within mf
, and
then takes the resulting value and wraps it back up into a new applicative-functor.
param | ma | Value(s) applicative functor |
param | mf | Mapping function(s) |
returns | Mapped applicative functor |
method B Match <B> (Func<A, B> Succ, Func<Error, B> Fail) Source #
Invokes the Succ or Fail function depending on the state of the structure
type | B | Return type |
param | Succ | Function to invoke if in a Succ state |
param | Fail | Function to invoke if in a Fail state |
returns | The return value of the invoked function |
method int GetHashCode <HashA> () Source #
Get a hash code for the structure
method int CompareTo <OrdA> (Fin<A>? other) Source #
Compare this structure to another to find its relative ordering
method Fin<B> Map <B> (Func<A, B> Succ) Source #
Maps the value in the structure
param | f | Map function |
returns | Mapped structure |
method Fin<A> MapFail (Func<Error, Error> f) Source #
Maps the value in the structure
param | f | Map function |
returns | Mapped structure |
method Fin<B> BiMap <B> (Func<A, B> Succ, Func<Error, Error> Fail) Source #
Bi-maps the structure
returns | Mapped Either |
method Fin<B> Bind <B> (Func<A, Fin<B>> f) Source #
Monadic bind
type | B | Resulting bound value |
param | f | Bind function |
returns | Bound structure |
method Fin<B> BiBind <B> ( Func<A, Fin<B>> Succ, Func<Error, Fin<B>> Fail) Source #
Bi-bind. Allows mapping of both monad states
method void Deconstruct (out A value) Source #