Fin
monads support 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 = FinSucc(123);
Fin<int> mb = FinFail(Error.New("Error!"));
- Fin <A>
- IsSucc
- Succ (A value)
- Fail (Error error)
- Fail (string error)
- IsFail
- IsBottom
- Case
- Equals (object obj)
- GetHashCode ()
- | (Fin<A> left, Fin<A> right)
- true (Fin<A> ma)
- false (Fin<A> ma)
- < (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, A rhs)
- == (A lhs, Fin<A> rhs)
- == (Fin<A> lhs, Fin<A> rhs)
- != (Fin<A> lhs, A rhs)
- != (A lhs, Fin<A> rhs)
- != (Fin<A> lhs, Fin<A> rhs)
- == (Fin<A> lhs, Error rhs)
- == (Error lhs, Fin<A> rhs)
- != (Fin<A> lhs, Error rhs)
- != (Error lhs, Fin<A> rhs)
- CompareTo (Fin<A> other)
- Equals (Fin<A> other)
- GetEnumerator ()
- ToString ()
- GetObjectData (SerializationInfo info, StreamingContext context)
- CompareTo (object obj)
- Match <B> (Func<A, B> Succ, Func<Error, B> Fail)
- Match (Action<A> Succ, Action<Error> Fail)
- IfFail (Func<Error, A> Fail)
- IfFail (in A alternative)
- IfFail (Action<Error> Fail)
- IfSucc (Action<A> Succ)
- Iter (Action<A> Succ)
- Do (Action<A> Succ)
- Fold <S> (in 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)
- Map <B> (Func<A, B> f)
- BiMap <B> (Func<A, B> Succ, Func<Error, Error> Fail)
- BiMap <B> (Func<A, B> Succ, Func<Error, B> Fail)
- Select <B> (Func<A, B> f)
- Bind <B> (Func<A, Fin<B>> f)
- BiBind <B> (Func<A, Fin<B>> Succ, Func<Error, Fin<B>> Fail)
- SelectMany <B> (Func<A, Fin<B>> f)
- SelectMany <B, C> (Func<A, Fin<B>> bind, Func<A, B, C> project)
- ToList ()
- ToLst ()
- ToSeq ()
- ToArr ()
- ToArray ()
- ToOption ()
- ToOptionAsync ()
- ToOptionUnsafe ()
- ToEither ()
- ToEitherUnsafe ()
- ToEitherAsync ()
- ToEff ()
- ToAff ()
- ThrowIfFail ()
- FinExtensions
- 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)
- Apply <A, B> (this Fin<Func<A, B>> fab, Fin<A> fa)
- Apply <A, B> (this Func<A, B> fab, Fin<A> fa)
- Apply <A, B, C> (this Fin<Func<A, B, C>> fabc, Fin<A> fa, Fin<B> fb)
- Apply <A, B, C> (this Func<A, B, C> fabc, Fin<A> fa, Fin<B> fb)
- Apply <A, B, C> (this Fin<Func<A, B, C>> fabc, Fin<A> fa)
- Apply <A, B, C> (this Func<A, B, C> fabc, Fin<A> fa)
- Apply <A, B, C> (this Fin<Func<A, Func<B, C>>> fabc, Fin<A> fa)
- Apply <A, B, C> (this Func<A, Func<B, C>> fabc, Fin<A> fa)
- Action <A, B> (this Fin<A> fa, Fin<B> fb)
- 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)
- FinGuardExtensions
- ToFin (this Guard<Error> ma)
- SelectMany <B> (this Guard<Error> ma, Func<Unit, Fin<B>> f)
- SelectMany <B, C> (this Guard<Error> ma, Func<Unit, Fin<B>> bind, Func<Unit, B, C> project)
- SelectMany <A> (this Fin<A> ma, Func<A, Guard<Error>> f)
- SelectMany <A, C> (this Fin<A> ma, Func<A, Guard<Error>> bind, Func<A, Unit, C> project)
- 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)
- apply <A, B> (Fin<Func<A, B>> fab, Fin<A> fa)
- apply <A, B> (Func<A, B> fab, Fin<A> fa)
- apply <A, B, C> (Fin<Func<A, B, C>> fabc, Fin<A> fa, Fin<B> fb)
- apply <A, B, C> (Func<A, B, C> fabc, Fin<A> fa, Fin<B> fb)
- apply <A, B, C> (Fin<Func<A, B, C>> fabc, Fin<A> fa)
- apply <A, B, C> (Func<A, B, C> fabc, Fin<A> fa)
- apply <A, B, C> (Fin<Func<A, Func<B, C>>> fabc, Fin<A> fa)
- apply <A, B, C> (Func<A, Func<B, C>> fabc, Fin<A> fa)
- action <A, B> (Fin<A> fa, Fin<B> fb)
- 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)
- fold <S, A> (Fin<A> ma, S state, Func<S, A, S> folder)
- 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)
Equivalent of Either<Error, A>
Called Fin
because it is expected to be used as the concrete result of a computation
method int GetHashCode () Source #
Get hash code
method IEnumerator<A> GetEnumerator () Source #
method void GetObjectData (SerializationInfo info, StreamingContext context) Source #
method Fin<B> SelectMany <B> (Func<A, Fin<B>> f) Source #
method Fin<C> SelectMany <B, C> (Func<A, Fin<B>> bind, Func<A, B, C> project) Source #
method OptionAsync<A> ToOptionAsync () Source #
method OptionUnsafe<A> ToOptionUnsafe () Source #
method EitherUnsafe<Error, A> ToEitherUnsafe () Source #
method EitherAsync<Error, A> ToEitherAsync () 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<R> Plus <NUM, R> (this Fin<R> x, Fin<R> y) Source #
Add the bound values of x and y, uses an Add type-class to provide the add operation for type A. For example x.Add<TInteger,int>(y)
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 type-class 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 type-class 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 type-class 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 Fin<B> Apply <A, B> (this Fin<Func<A, B>> fab, Fin<A> fa) Source #
Apply
param | fab | Function to apply the applicative to |
param | fa | Applicative to apply |
returns | Applicative of type FB derived from Applicative of B |
method Fin<B> Apply <A, B> (this Func<A, B> fab, Fin<A> fa) Source #
Apply
param | fab | Function to apply the applicative to |
param | fa | Applicative to apply |
returns | Applicative of type FB derived from Applicative of B |
method Fin<C> Apply <A, B, C> (this Fin<Func<A, B, C>> fabc, Fin<A> fa, Fin<B> fb) Source #
Apply
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 Fin<C> Apply <A, B, C> (this Func<A, B, C> fabc, Fin<A> fa, Fin<B> fb) Source #
Apply
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 Fin<Func<B, C>> Apply <A, B, C> (this Fin<Func<A, B, C>> fabc, Fin<A> fa) Source #
Apply
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 Fin<Func<B, C>> Apply <A, B, C> (this Func<A, B, C> fabc, Fin<A> fa) Source #
Apply
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 Fin<Func<B, C>> Apply <A, B, C> (this Fin<Func<A, Func<B, C>>> fabc, Fin<A> fa) Source #
Apply
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 Fin<Func<B, C>> Apply <A, B, C> (this Func<A, Func<B, C>> fabc, Fin<A> fa) Source #
Apply
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 Fin<B> Action <A, B> (this Fin<A> fa, Fin<B> fb) Source #
Evaluate fa, then fb, ignoring the result of fa
param | fa | Applicative to evaluate first |
param | fb | Applicative to evaluate second and then return |
returns | Applicative of type Fin |
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.
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> (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.
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 |
class FinGuardExtensions Source #
method Fin<B> SelectMany <B> (this Guard<Error> ma, Func<Unit, Fin<B>> f) Source #
method Fin<C> SelectMany <B, C> (this Guard<Error> 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>> f) Source #
method Fin<C> SelectMany <A, C> (this Fin<A> ma, Func<A, Guard<Error>> 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 type-class 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 type-class 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 type-class 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 type-class 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 Fin<B> apply <A, B> (Fin<Func<A, B>> fab, Fin<A> fa) Source #
Apply
param | fab | Function to apply the applicative to |
param | fa | Applicative to apply |
returns | Applicative of type FB derived from Applicative of B |
method Fin<B> apply <A, B> (Func<A, B> fab, Fin<A> fa) Source #
Apply
param | fab | Function to apply the applicative to |
param | fa | Applicative to apply |
returns | Applicative of type FB derived from Applicative of B |
method Fin<C> apply <A, B, C> (Fin<Func<A, B, C>> fabc, Fin<A> fa, Fin<B> fb) Source #
Apply
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 Fin<C> apply <A, B, C> (Func<A, B, C> fabc, Fin<A> fa, Fin<B> fb) Source #
Apply
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 Fin<Func<B, C>> apply <A, B, C> (Fin<Func<A, B, C>> fabc, Fin<A> fa) Source #
Apply
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 Fin<Func<B, C>> apply <A, B, C> (Func<A, B, C> fabc, Fin<A> fa) Source #
Apply
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 Fin<Func<B, C>> apply <A, B, C> (Fin<Func<A, Func<B, C>>> fabc, Fin<A> fa) Source #
Apply
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 Fin<Func<B, C>> apply <A, B, C> (Func<A, Func<B, C>> fabc, Fin<A> fa) Source #
Apply
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 Fin<B> action <A, B> (Fin<A> fa, Fin<B> fb) Source #
Evaluate fa, then fb, ignoring the result of fa
param | fa | Applicative to evaluate first |
param | fb | Applicative to evaluate second and then return |
returns | Applicative of type Fin |
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 fold <S, A> (Fin<A> ma, S state, Func<S, A, S> folder) 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 | folder | Folder function, applied if structure is in a Succ state |
returns | The aggregate state |
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 |