LanguageExt.Core

LanguageExt.Core Monads Alternative Monads Validation

Contents

record Validation <F, A> Source #

where F : Monoid<F>

Like Either but collects the failed values

Parameters

type MonoidFail
type F
type A

Properties

property bool IsSuccess Source #

Is the Validation in a Success state?

property bool IsFail Source #

Is the Validation in a Fail state?

property Validation<F, A> Empty Source #

Monoid empty

Methods

method Validation<F, A> Success (A value) Source #

method Validation<F, A> Fail (F value) Source #

method B Match <B> (Func<A, B> Succ, Func<F, B> Fail) Source #

Invokes the Success or Fail function depending on the state of the Validation

Parameters

type B

Return type

param Fail

Function to invoke if in a Fail state

param Succ

Function to invoke if in a Success state

returns

The return value of the invoked function

method ReadOnlySpan<F> FailSpan () Source #

Empty span

method ReadOnlySpan<A> SuccessSpan () Source #

Span of right value

method int CompareTo <OrdF, OrdA> (Validation<F, A> other) Source #

where OrdF : Ord<F>
where OrdA : Ord<A>

Compare this structure to another to find its relative ordering

method bool Equals <EqF, EqA> (Validation<F, A> other) Source #

where EqF : Eq<F>
where EqA : Eq<A>

Equality override

method Validation<F, B> Map <B> (Func<A, B> f) Source #

Maps the value in the Validation if it's in a Success state

Parameters

type F

Fail

type A

Success

type B

Mapped Validation type

param f

Map function

returns

Mapped Validation

method Validation<F1, A1> BiMap <F1, A1> (Func<A, A1> Succ, Func<F, F1> Fail) Source #

where F1 : Monoid<F1>

Bi-maps the value in the Validation if it's in a Success state

Parameters

type F

Fail

type A

Success

type F1

Fail return

type A1

Success return

param Succ

Success map function

param Fail

Fail map function

returns

Mapped Validation

method Validation<F, B> Bind <B> (Func<A, Validation<F, B>> f) Source #

Monadic bind

Parameters

type F

Fail

type A

Success

type B

Resulting bound value

param f

Bind function

returns

Bound Validation

method Validation<F1, A1> BiBind <F1, A1> ( Func<A, Validation<F1, A1>> Succ, Func<F, Validation<F1, A1>> Fail) Source #

where F1 : Monoid<F1>

Bi-bind. Allows mapping of both monad states

method Validation<F1, A> BindFail <F1> ( Func<F, Validation<F1, A>> Fail) Source #

where F1 : Monoid<F1>

Bind the failure

method Unit Match (Action<A> Succ, Action<F> Fail) Source #

Invokes the Succ or Fail action depending on the state of the value

Parameters

param Succ

Action to invoke if in a Success state

param Fail

Action to invoke if in a Fail state

returns

Unit

method A IfFail (Func<A> Fail) Source #

Executes the Fail function if the value is in a Fail state. Returns the Success value if the value is in a Success state.

Parameters

param Fail

Function to generate a value if in the Fail state

returns

Returns an unwrapped value

method A IfFail (Func<F, A> failMap) Source #

Executes the failMap function if the value is in a Fail state. Returns the Success value if in a Success state.

Parameters

param failMap

Function to generate a value if in the Fail state

returns

Returns an unwrapped value

method A IfFail (A successValue) Source #

Returns the successValue if in a Fail state. Returns the Success value if in a Success state.

Parameters

param successValue

Value to return if in the Fail state

returns

Returns an unwrapped value

method Unit IfFail (Action<F> Fail) Source #

Executes the Fail action if in a Fail state.

Parameters

param Fail

Function to generate a Success value if in the Fail state

returns

Returns unit

method Unit IfRight (Action<A> Success) Source #

Invokes the Success action if in a Success state, otherwise does nothing

Parameters

param Success

Action to invoke

returns

Unit

method ValidationUnitContext<F, A> Success (Action<A> success) Source #

Match Success and return a context. You must follow this with .Fail(...) to complete the match

Parameters

param success

Action to invoke if in a Success state

returns

Context that must have Fail() called upon it.

method ValidationContext<F, A, B> Success <B> (Func<A, B> success) Source #

Match Success and return a context. You must follow this with .Fail(...) to complete the match

Parameters

param success

Action to invoke if in a Success state

returns

Context that must have Fail() called upon it.

method int CompareTo (object? obj) Source #

method IEnumerator<A> GetEnumerator () Source #

method Lst<F> FailToList () Source #

Project the value into a Lst<F>

Parameters

returns

If in a Fail state, a Lst of L with one item. A zero length Lst of L otherwise

method Arr<F> FailToArray () Source #

Project into an Arr<F>

Parameters

returns

If in a Fail state, a Arr of L with one item. A zero length Arr of L otherwise

method Lst<A> ToList () Source #

Project into a Lst<A>

Parameters

returns

If in a Success state, a Lst of R with one item. A zero length Lst of R otherwise

method Arr<A> ToArray () Source #

Project into an Arr<A>

Parameters

returns

If in a Success state, an Arr of R with one item. A zero length Arr of R otherwise

method Seq<A> ToSeq () Source #

Convert to sequence of 0 or 1 success values

method Seq<F> FailToSeq () Source #

Convert either to sequence of 0 or 1 left values

method Either<F, A> ToEither () Source #

method Option<A> ToOption () Source #

Convert to an Option

Parameters

returns

Some(Right) or None

method StreamT<M, A> ToStream <M> () Source #

where M : Monad<M>

Convert to a stream

method StreamT<M, F> FailToStream <M> () Source #

where M : Monad<M>

Convert to a stream

method int CompareTo (Validation<F, A>? other) Source #

CompareTo override

method int CompareTo <OrdR> (Validation<F, A> other) Source #

where OrdR : Ord<A>

CompareTo override

method int CompareTo (Fail<F> other) Source #

CompareTo override

method int CompareTo (Pure<A> other) Source #

CompareTo override

method int CompareTo (A? other) Source #

CompareTo override

method int CompareTo (F? other) Source #

CompareTo override

method bool Equals (A? other) Source #

Equality override

method bool Equals (F? other) Source #

Equality override

method bool Equals (Validation<F, A>? other) Source #

Equality override

method bool Equals <EqR> (Validation<F, A> other) Source #

where EqR : Eq<A>

Equality override

method bool Equals (Fail<F> other) Source #

Equality override

method bool Equals (Pure<A> other) Source #

Equality override

method B MatchUntyped <B> (Func<object?, B> Succ, Func<object?, B> Fail) Source #

Match the Success and Fail values but as untyped objects.

method Unit Iter (Action<A> Succ) Source #

Iterate the value action is invoked if in the Success state

method bool ForAll (Func<A, bool> Succ) Source #

Invokes a predicate on the success value if it's in the Success state

Parameters

returns

True if in a Left state. True if the in a Right state and the predicate returns True. False otherwise.

method bool BiForAll (Func<A, bool> Succ, Func<F, bool> Fail) Source #

Invokes a predicate on the values

Parameters

type L

Left

type R

Right

param self

Either to forall

param Succ

Predicate

param Fail

Predicate

returns

True if either Predicate returns true

method S Fold <S> (S state, Func<S, A, S> Succ) Source #

Validation types are like lists of 0 or 1 items and therefore follow the same rules when folding.

Parameters

type S

Aggregate state type

param state

Initial state

param Succ

Folder function, applied if structure is in a Success state

returns

The aggregate state

method S BiFold <S> (S state, Func<S, A, S> Succ, Func<S, F, S> Fail) Source #

Either types are like lists of 0 or 1 items, and therefore follow the Validation types are like lists of 0 or 1 items and therefore follow the same rules when folding.

Parameters

type S

Aggregate state type

param state

Initial state

param Succ

Folder function, applied if in a Success state

param Fail

Folder function, applied if in a Fail state

returns

The aggregate state

method bool Exists (Func<A, bool> pred) Source #

Invokes a predicate on the value if it's in the Success state

Parameters

param pred

Predicate

returns

True if in a Success state and the predicate returns True. False otherwise.

method Validation<F, A> Do (Action<A> f) Source #

Impure iteration of the bound values in the structure

Parameters

returns

Returns the original unmodified structure

method K<AF, Validation<F, B>> Traverse <AF, B> (Func<A, K<AF, B>> f) Source #

where AF : Applicative<AF>

Map each element of a structure to an action, evaluate these actions from left to right, and collect the results.

Parameters

type F

Applicative functor trait

type B

Bound value (output)

param f
param ta

Traversable structure

method Validation<F1, A> MapFail <F1> (Func<F, F1> f) Source #

where F1 : Monoid<F1>

Maps the value in the Either if it's in a Left state

Parameters

type L

Left

type R

Right

type F1

Mapped Either type

param f

Map function

returns

Mapped Either

method Validation<F, B> Bind <B> (Func<A, K<Validation<F>, B>> f) Source #

Monadic bind

Parameters

type L

Left

type R

Right

type B
param f
returns

Bound Either

method Validation<F, A> Filter (Func<A, bool> pred) Source #

Filter the Validation

If the predicate returns false then the Validation goes into a failed state using Monoid.Empty of F as its failure value.

method Validation<F, A> Where (Func<A, bool> pred) Source #

Filter the Validation

If the predicate returns false then the Validation goes into a failed state using Monoid.Empty of F as its failure value.

method Validation<F, B> Select <B> (Func<A, B> f) Source #

Maps the bound value

method Validation<F, B> SelectMany <S, B> (Func<A, Validation<F, S>> bind, Func<A, S, B> project) Source #

Monadic bind function

method Validation<F, B> Bind <B> (Func<A, Pure<B>> f) Source #

Monadic bind

Parameters

param f

Bind function

method Validation<F, A> Bind (Func<A, Fail<F>> f) Source #

Monadic bind

Parameters

param f

Bind function

method Validation<F, Unit> Bind (Func<A, Guard<F, Unit>> f) Source #

Monadic bind

Parameters

param f

Bind function

method Validation<F, C> SelectMany <B, C> (Func<A, Pure<B>> bind, Func<A, B, C> project) Source #

Monadic bind and project

Parameters

param bind

Bind function

param project

Project function

method Validation<F, C> SelectMany <B, C> (Func<A, Fail<F>> bind, Func<A, B, C> _) Source #

Monadic bind and project

Parameters

param bind

Bind function

param project

Project function

method Validation<F, C> SelectMany <C> ( Func<A, Guard<F, Unit>> f, Func<A, Unit, C> project) Source #

Monadic bind and project

Parameters

param bind

Bind function

param project

Project function

method int GetHashCode () Source #

Operators

operator >> (Validation<F, A> lhs, Validation<F, A> rhs) Source #

Action operator

operator < (Validation<F, A> lhs, Fail<F> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs < rhs

operator <= (Validation<F, A> lhs, Fail<F> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs < rhs

operator > (Validation<F, A> lhs, Fail<F> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs < rhs

operator >= (Validation<F, A> lhs, Fail<F> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs < rhs

operator < (Validation<F, A> lhs, Pure<A> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs < rhs

operator <= (Validation<F, A> lhs, Pure<A> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs < rhs

operator > (Validation<F, A> lhs, Pure<A> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs < rhs

operator >= (Validation<F, A> lhs, Pure<A> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs < rhs

operator < (Fail<F> lhs, Validation<F, A> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs < rhs

operator <= (Fail<F> lhs, Validation<F, A> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs < rhs

operator > (Fail<F> lhs, Validation<F, A>rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs < rhs

operator >= (Fail<F> lhs, Validation<F, A> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs < rhs

operator < (Pure<A> lhs, Validation<F, A> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs < rhs

operator <= (Pure<A> lhs, Validation<F, A> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs < rhs

operator > (Pure<A> lhs, Validation<F, A> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs < rhs

operator >= (Pure<A> lhs, Validation<F, A> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs < rhs

operator < (Validation<F, A> lhs, Validation<F, A> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs < rhs

operator <= (Validation<F, A> lhs, Validation<F, A> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs <= rhs

operator > (Validation<F, A> lhs, Validation<F, A> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs > rhs

operator >= (Validation<F, A> lhs, Validation<F, A> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs >= rhs

operator == (Validation<F, A> lhs, Fail<F> rhs) Source #

Equality operator override

operator == (Validation<F, A> lhs, Pure<A> rhs) Source #

Equality operator override

operator == (Fail<F> lhs, Validation<F, A> rhs) Source #

Equality operator override

operator == (Pure<A> lhs, Validation<F, A> rhs) Source #

Equality operator override

operator != (Validation<F, A> lhs, Fail<F> rhs) Source #

Non-equality operator override

operator != (Validation<F, A> lhs, Pure<A> rhs) Source #

Non-equality operator override

operator != (Fail<F> lhs, Validation<F, A> rhs) Source #

Non-equality operator override

operator != (Pure<A> lhs, Validation<F, A> rhs) Source #

Non-equality operator override

operator + (Validation<F, A> lhs, Validation<F, A> rhs) Source #

Combine operator: uses the underlying F.Combine to collect failures

operator + (K<Validation<F>, A> lhs, Validation<F, A> rhs) Source #

Combine operator: uses the underlying F.Combine to collect failures

operator + (Validation<F, A> lhs, K<Validation<F>, A> rhs) Source #

Combine operator: uses the underlying F.Combine to collect failures

operator + (Validation<F, A> lhs, A rhs) Source #

Combine operator: uses the underlying F.Combine to collect failures

operator + (Validation<F, A> lhs, Pure<A> rhs) Source #

Combine operator: uses the underlying F.Combine to collect failures

operator + (Validation<F, A> lhs, Fail<F> rhs) Source #

Combine operator: uses the underlying F.Combine to collect failures

operator + (Validation<F, A> lhs, F rhs) Source #

Combine operator: uses the underlying F.Combine to collect failures

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

Choice operator: returns the first argument to succeed. If both fail, then the last failure is returned.

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

Choice operator: returns the first argument to succeed. If both fail, then the last failure is returned.

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

Choice operator: returns the first argument to succeed. If both fail, then the last failure is returned.

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

Choice operator: returns the first argument to succeed. If both fail, then the last failure is returned.

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

Choice operator: returns the first argument to succeed. If both fail, then the last failure is returned.

operator | (Validation<F, A> lhs, Fail<F> rhs) Source #

Choice operator: returns the first argument to succeed. If both fail, then the last failure is returned.

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

Choice operator: returns the first argument to succeed. If both fail, then the last failure is returned.

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

Catch operator: returns the first argument if it to succeeds. Otherwise, the F failure is mapped.

operator & (Validation<F, A> lhs, Validation<F, A> rhs) Source #

If any items are Fail then the errors are collected and returned. If they all pass then the Success values are collected into a Seq.

operator & (Validation<F, Seq<A>> lhs, Validation<F, A> rhs) Source #

If any items are Fail then the errors are collected and returned. If they all pass then the Success values are collected into a Seq.

operator & (Validation<F, A> lhs, Validation<F, Seq<A>> rhs) Source #

If any items are Fail then the errors are collected and returned. If they all pass then the Success values are collected into a Seq.

operator true (Validation<F, A> value) Source #

Override of the True operator to return True if the Either is Right

operator false (Validation<F, A> value) Source #

Override of the False operator to return True if the Either is Left

struct ValidationContext <F, A, B> Source #

where F : Monoid<F>

Context for the fluent Either matching

Methods

method B Fail (Func<F, B> fail) Source #

Fail match

Parameters

param Fail
returns

Result of the match

struct ValidationUnitContext <F, A> Source #

where F : Monoid<F>

Context for the fluent Validation matching

Methods

method Unit Left (Action<F> fail) Source #

class ValidationExtensions Source #

Methods

method Validation<F, A> As <F, A> (this K<Validation<F>, A> ma) Source #

where F : Monoid<F>

method Validation<L, A> Flatten <L, A> (this Validation<L, Validation<L, A>> mma) Source #

where L : Monoid<L>

Monadic join

method IEnumerable<S> Successes <F, S> (this IEnumerable<Validation<F, S>> vs) Source #

where F : Monoid<F>

Extract only the successes

Parameters

type F

Fail type

type S

Success type

param vs

Enumerable of validations

returns

Enumerable of successes

method IEnumerable<F> Fails <F, S> (this IEnumerable<Validation<F, S>> vs) Source #

where F : Monoid<F>

Extract only the failures

Parameters

type F

Fail type

type S

Success type

param vs

Enumerable of validations

returns

Enumerable of failures

method Seq<S> Successes <F, S> (this Seq<Validation<F, S>> vs) Source #

where F : Monoid<F>

Extract only the successes

Parameters

type F

Fail type

type S

Success type

param vs

Seq of validations

returns

Enumerable of successes

method Seq<F> Fails <F, S> (this Seq<Validation<F, S>> vs) Source #

where F : Monoid<F>

Extract only the failures

Parameters

type F

Fail type

type S

Success type

param vs

Seq of validations

returns

Enumerable of failures

method Fin<A> ToFin <A> (this Validation<Error, A> ma) Source #

Convert Validation type to Fin type.

class ValidationExtensions Source #

Methods

method Validation<F, B> Map <F, A, B> (this Func<A, B> f, K<Validation<F>, A> ma) Source #

where F : Monoid<F>

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.

Parameters

param ma

Functor to map

param f

Mapping function

returns

Mapped functor

method Validation<F, B> Map <F, A, B> (this Func<A, B> f, Validation<F, A> ma) Source #

where F : Monoid<F>

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.

Parameters

param ma

Functor to map

param f

Mapping function

returns

Mapped functor

method Validation<F, B> Action <F, A, B> (this Validation<F, A> ma, K<Validation<F>, B> mb) Source #

where F : Monoid<F>

Applicative action: runs the first applicative, ignores the result, and returns the second applicative

method Validation<F, B> Action <F, A, B> (this K<Validation<F>, A> ma, K<Validation<F>, B> mb) Source #

where F : Monoid<F>

Applicative action: runs the first applicative, ignores the result, and returns the second applicative

method Validation<F, B> Apply <F, A, B> (this Validation<F, Func<A, B>> mf, K<Validation<F>, A> ma) Source #

where F : Monoid<F>

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.

Parameters

param ma

Value(s) applicative functor

param mf

Mapping function(s)

returns

Mapped applicative functor

method Validation<F, B> Apply <F, A, B> (this K<Validation<F>, Func<A, B>> mf, K<Validation<F>, A> ma) Source #

where F : Monoid<F>

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.

Parameters

param ma

Value(s) applicative functor

param mf

Mapping function(s)

returns

Mapped applicative functor

record Fail <F, A> (F Value) Source #

where F : Monoid<F>

Properties

property bool IsSuccess Source #

Is the Validation in a Success state?

property bool IsFail Source #

Is the Validation in a Fail state?

Methods

method B Match <B> (Func<A, B> Succ, Func<F, B> Fail) Source #

Invokes the Success or Fail function depending on the state of the Validation

Parameters

type B

Return type

param Succ

Function to invoke if in a Success state

param Fail

Function to invoke if in a Fail state

returns

The return value of the invoked function

method string ToString () Source #

Show the structure as a string

method int GetHashCode () Source #

Get a hash code for the structure

method ReadOnlySpan<F> FailSpan () Source #

Span of left value

method ReadOnlySpan<A> SuccessSpan () Source #

Empty span

method int CompareTo <OrdF, OrdA> (Validation<F, A> other) Source #

Compare this structure to another to find its relative ordering

method bool Equals <EqF, EqA> (Validation<F, A> other) Source #

Equality override

method Validation<F, B> Map <B> (Func<A, B> f) Source #

Maps the value in the Validation if it's in a Success state

Parameters

type F

Fail

type A

Success

type B

Mapped Validation type

param f

Map function

returns

Mapped Validation

method Validation<L2, R2> BiMap <L2, R2> (Func<A, R2> Succ, Func<F, L2> Fail) Source #

Bi-maps the value in the Validation if it's in a Success state

Parameters

type F

Fail

type A

Success

type L2

Fail return

type R2

Success return

param Succ

Success map function

param Fail

Fail map function

returns

Mapped Validation

method Validation<F, B> Bind <B> (Func<A, Validation<F, B>> f) Source #

Monadic bind

Parameters

type F

Fail

type A

Success

type B

Resulting bound value

param f

Bind function

returns

Bound Validation

method Validation<L2, R2> BiBind <L2, R2> ( Func<A, Validation<L2, R2>> Succ, Func<F, Validation<L2, R2>> Fail) Source #

Bi-bind. Allows mapping of both monad states

class ValidationGuardExtensions Source #

Methods

method Validation<F, C> SelectMany <F, A, C> ( this Validation<F, A> ma, Func<A, Guard<F, Unit>> f, Func<A, Unit, C> project) Source #

where F : Monoid<F>

class Validation <FAIL> Source #

where FAIL : Monoid<FAIL>

Trait implementation for Validation

Parameters

type M

Given monad trait

class Prelude Source #

Methods

method Validation<F, A> Success <F, A> (A value) Source #

where F : Monoid<F>

Represents a successful operation

Parameters

type F

Error type

type A

Value type

param value

Value

returns

Validation applicative

method Validation<F, A> Fail <F, A> (F value) Source #

where F : Monoid<F>

Represents a failed operation

Parameters

type F

Error type

type A

Value type

param value

Error value

returns

Validation applicative

method Validation<F, A> Fail <F, A> (Seq<F> values) Source #

where F : Monoid<F>

Represents a failed operation

Parameters

type F

Error type

type A

Value type

param value

Error value

returns

Validation applicative

class Prelude Source #

Methods

method Validation<F, B> map <F, A, B> (Func<A, B> f, K<Validation<F>, A> ma) Source #

where F : Monoid<F>

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.

Parameters

param ma

Functor to map

param f

Mapping function

returns

Mapped functor

method Validation<F, B> action <F, A, B> (K<Validation<F>, A> ma, K<Validation<F>, B> mb) Source #

where F : Monoid<F>

Applicative action: runs the first applicative, ignores the result, and returns the second applicative

method Validation<F, B> apply <F, A, B> (K<Validation<F>, Func<A, B>> mf, K<Validation<F>, A> ma) Source #

where F : Monoid<F>

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.

Parameters

param ma

Value(s) applicative functor

param mf

Mapping function(s)

returns

Mapped applicative functor

record Success <F, A> (A Value) Source #

where F : Monoid<F>

Properties

property bool IsSuccess Source #

Is the Validation in a Success state?

property bool IsFail Source #

Is the Validation in a Left state?

Methods

method B Match <B> ( Func<A, B> Succ, Func<F, B> Fail) Source #

Invokes the Success or Left function depending on the state of the Validation

Parameters

type B

Return type

param Left

Function to invoke if in a Left state

param Success

Function to invoke if in a Success state

returns

The return value of the invoked function

method string ToString () Source #

Show the structure as a string

method int GetHashCode () Source #

Get a hash code for the structure

method ReadOnlySpan<F> FailSpan () Source #

Empty span

method ReadOnlySpan<A> SuccessSpan () Source #

Span of right value

method int CompareTo <OrdF, OrdA> (Validation<F, A> other) Source #

Compare this structure to another to find its relative ordering

method bool Equals <EqF, EqA> (Validation<F, A> other) Source #

Equality override

method Validation<F, B> Map <B> (Func<A, B> f) Source #

Maps the value in the Validation if it's in a Success state

Parameters

type F

Left

type A

Success

type B

Mapped Validation type

param f

Map function

returns

Mapped Validation

method Validation<L2, R2> BiMap <L2, R2> ( Func<A, R2> Succ, Func<F, L2> Left) Source #

Bi-maps the value in the Validation if it's in a Success state

Parameters

type F

Left

type A

Success

type L2

Left return

type R2

Success return

param Success

Success map function

param Left

Left map function

returns

Mapped Validation

method Validation<F, B> Bind <B> (Func<A, Validation<F, B>> f) Source #

Monadic bind

Parameters

type F

Left

type A

Success

type B

Resulting bound value

param f

Bind function

returns

Bound Validation

method Validation<L2, R2> BiBind <L2, R2> ( Func<A, Validation<L2, R2>> Succ, Func<F, Validation<L2, R2>> Fail) Source #

Bi-bind. Allows mapping of both monad states