LanguageExt.Core

LanguageExt.Core Monads Alternative Monads Validation Extensions

Contents

class ValidationExtensions Source #

Methods

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

where F : Semigroup<F>

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

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

where F : Semigroup<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

class ValidationExtensions Source #

Methods

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

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

method Validation<F, A> Combine <F, A> (this K<Validation<F>, A> lhs, K<Validation<F>, A> rhs) Source #

where F : Semigroup<F>

method Validation<F, A> Choose <F, A> (this K<Validation<F>, A> lhs, K<Validation<F>, A> rhs) Source #

method ValidationUnitContext<F, A> Success <F, A> (this K<Validation<F>, A> ma, 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 <F, A, B> (this K<Validation<F>, A> ma, 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 Validation<F, A> Flatten <F, A> (this Validation<F, Validation<F, A>> mma) Source #

Monadic join

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

where F : Monoid<F>

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 <F, A> (this K<Validation<F>, A> ma, Func<A, bool> pred) Source #

where F : Monoid<F>

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 IEnumerable<S> Successes <F, S> (this IEnumerable<Validation<F, S>> vs) Source #

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 #

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 #

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 #

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.

method Validation<F, Seq<A>> CombineI <F, A> ( this Validation<F, Seq<A>> lhs, Validation<F, A> rhs, Option<SemigroupInstance<F>> trait) 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.

class ValidationExtensions Source #

Methods

method Validation<F, B> Map <F, A, B> (this Func<A, B> f, K<Validation<F>, 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.

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

class ValidationGuardExtensions Source #

Methods

method Validation<F, Unit> ToValidation <F> (this Guard<F, Unit> guard) Source #

where F : Monoid<F>

Natural transformation to Validation

method Validation<F, B> Bind <F, B> ( this Guard<F, Unit> guard, Func<Unit, Validation<F, B>> f) Source #

where F : Monoid<F>

Monadic binding support for Validation

method Validation<F, C> SelectMany <F, B, C> ( this Guard<F, Unit> guard, Func<Unit, Validation<F, B>> bind, Func<Unit, B, C> project) Source #

where F : Monoid<F>

Monadic binding support for Validation