FSharpPlus


Validation Module

Functions and values

Function or value Description

_Failure x

Full Usage: _Failure x

Parameters:
    x : 'a -> ^b

Returns: Validation<'c, 'a> -> ^e
Modifiers: inline
x : 'a -> ^b
Returns: Validation<'c, 'a> -> ^e

_Success x

Full Usage: _Success x

Parameters:
    x : 'a -> ^b

Returns: Validation<'a, 'd> -> ^e
Modifiers: inline
x : 'a -> ^b
Returns: Validation<'a, 'd> -> ^e

appValidation combine e1' e2'

Full Usage: appValidation combine e1' e2'

Parameters:
Returns: Validation<'err, 'a>

Takes two Validations and returns the first Success. If both are Failures it returns both Failures combined with the supplied function.

combine : 'err -> 'err -> 'err
e1' : Validation<'err, 'a>
e2' : Validation<'err, 'a>
Returns: Validation<'err, 'a>

apply f x

Full Usage: apply f x

Parameters:
Returns: Validation<^Error, 'U>
Modifiers: inline
Type parameters: ^Error, 'T, 'U

Applies the wrapped value to the wrapped function when both are Success and returns a wrapped result or the Failure(s). The function wrapped in a Success or a Failure. The value wrapped in a Success or a Failure. A Success of the function applied to the value when both are Success, or the Failure(s) if more than one, combined with the Semigroup (++) operation of the Error type.

f : Validation<^Error, ('T -> 'U)>
x : Validation<^Error, 'T>
Returns: Validation<^Error, 'U>

bifoldBack f g source state

Full Usage: bifoldBack f g source state

Parameters:
    f : 'Error -> 'State -> 'State
    g : 'T -> 'State -> 'State
    source : Validation<'Error, 'T>
    state : 'State

Returns: 'State
f : 'Error -> 'State -> 'State
g : 'T -> 'State -> 'State
source : Validation<'Error, 'T>
state : 'State
Returns: 'State

bimap failureMapper successMapper source

Full Usage: bimap failureMapper successMapper source

Parameters:
    failureMapper : 'TError -> 'UError - Function to be applied to source, if it contains a Failure value.
    successMapper : 'T -> 'U - Function to be applied to source, if it contains a Success value.
    source : Validation<'TError, 'T> - The source value, containing a Success or a Failure.

Returns: Validation<'UError, 'U> The result of applying the corresponding mapping function.

Maps both success and failure of a Validation.

failureMapper : 'TError -> 'UError

Function to be applied to source, if it contains a Failure value.

successMapper : 'T -> 'U

Function to be applied to source, if it contains a Success value.

source : Validation<'TError, 'T>

The source value, containing a Success or a Failure.

Returns: Validation<'UError, 'U>

The result of applying the corresponding mapping function.

bind f x

Full Usage: bind f x

Parameters:
Returns: Validation<'Error, 'U>

Binds through a Validation, which is useful for composing Validations sequentially. Note that despite having a bind function of the correct type, Validation is not a monad. The reason is, this bind does not accumulate errors, so it does not agree with the Applicative instance. There is nothing wrong with using this function, it just does not make a valid Monad instance.

f : 'T -> Validation<'Error, 'U>
x : Validation<'Error, 'T>
Returns: Validation<'Error, 'U>

bisequence source

Full Usage: bisequence source

Parameters:
    source : Validation<^Functor<'Error>, ^Functor<'T>>

Returns: ^Functor>
Modifiers: inline

Like sequence but traversing the Failure part as well.

source : Validation<^Functor<'Error>, ^Functor<'T>>
Returns: ^Functor>

bitraverse f g source

Full Usage: bitraverse f g source

Parameters:
    f : 'TError -> ^Functor<'UError>
    g : 'T -> ^Functor<'U>
    source : Validation<'TError, 'T>

Returns: ^Functor>
Modifiers: inline
Type parameters: 'TError, ^Functor<'UError>, ^Functor<Validation<'UError, 'U>>, ^Functor<'U>, 'T2, 'Error2, 'T

Like traverse but taking an additional function to traverse the Failure part as well.

f : 'TError -> ^Functor<'UError>
g : 'T -> ^Functor<'U>
source : Validation<'TError, 'T>
Returns: ^Functor>

defaultValue value source

Full Usage: defaultValue value source

Parameters:
Returns: 'T

Extracts the Success value or use the supplied default value when it's a Failure.

value : 'T
source : Validation<'Error, 'T>
Returns: 'T

defaultWith compensation source

Full Usage: defaultWith compensation source

Parameters:
    compensation : 'Error -> 'T
    source : Validation<'Error, 'T>

Returns: 'T

Extracts the Success value or applies the compensation function over the Failure.

compensation : 'Error -> 'T
source : Validation<'Error, 'T>
Returns: 'T

either failureMapper successMapper source

Full Usage: either failureMapper successMapper source

Parameters:
    failureMapper : 'TError -> 'U - Function to be applied to source, if it contains a Failure value.
    successMapper : 'T -> 'U - Function to be applied to source, if it contains a Success value.
    source : Validation<'TError, 'T> - The source value, containing a Success or a Failure.

Returns: 'U The result of applying either functions.

Extracts a value from either side of a Validation.

failureMapper : 'TError -> 'U

Function to be applied to source, if it contains a Failure value.

successMapper : 'T -> 'U

Function to be applied to source, if it contains a Success value.

source : Validation<'TError, 'T>

The source value, containing a Success or a Failure.

Returns: 'U

The result of applying either functions.

foldBack folder source state

Full Usage: foldBack folder source state

Parameters:
    folder : 'T -> 'State -> 'State
    source : Validation<'Error, 'T>
    state : 'State

Returns: 'State
Modifiers: inline
Type parameters: 'T, 'State, 'Error
folder : 'T -> 'State -> 'State
source : Validation<'Error, 'T>
state : 'State
Returns: 'State

isoValidationResult x

Full Usage: isoValidationResult x

Parameters:
    x : ^a

Returns: ^b
Modifiers: inline
x : ^a
Returns: ^b

liftChoice f

Full Usage: liftChoice f

Parameters:
    f : 'b -> 'Semigroup

Returns: Choice<'b, 'T> -> Validation<'Semigroup, 'T>

Converting a 'Choice' to a 'Validation' when the 'Choice2Of2' of the 'Choice' needs to be lifted into a 'Semigroup'.

f : 'b -> 'Semigroup
Returns: Choice<'b, 'T> -> Validation<'Semigroup, 'T>

liftResult f _arg1

Full Usage: liftResult f _arg1

Parameters:
    f : 'Error -> 'Semigroup
    _arg1 : Result<'T, 'Error>

Returns: Validation<'Semigroup, 'T>

Converts a 'Result' to a 'Validation' when the 'Error' of the 'Result' needs to be lifted into a 'Semigroup'.

f : 'Error -> 'Semigroup
_arg1 : Result<'T, 'Error>
Returns: Validation<'Semigroup, 'T>

map f source

Full Usage: map f source

Parameters:
Returns: Validation<'Error, 'U>
f : 'T -> 'U
source : Validation<'Error, 'T>
Returns: Validation<'Error, 'U>

map2 f x y

Full Usage: map2 f x y

Parameters:
Returns: Validation<^Error, 'V>
Modifiers: inline
Type parameters: 'T, 'U, 'V, ^Error
f : 'T -> 'U -> 'V
x : Validation<^Error, 'T>
y : Validation<^Error, 'U>
Returns: Validation<^Error, 'V>

map3 f x y z

Full Usage: map3 f x y z

Parameters:
Returns: Validation<^Error, 'W>
Modifiers: inline
Type parameters: 'T, 'U, 'V, 'W, ^Error
f : 'T -> 'U -> 'V -> 'W
x : Validation<^Error, 'T>
y : Validation<^Error, 'U>
z : Validation<^Error, 'V>
Returns: Validation<^Error, 'W>

ofChoice x

Full Usage: ofChoice x

Parameters:
Returns: Validation<'Error, 'T>

Creates a Validation<'Error,'T> from a Choice<'T,'Error>.

x : Choice<'T, 'Error>
Returns: Validation<'Error, 'T>

ofOptionWith errorValue source

Full Usage: ofOptionWith errorValue source

Parameters:
    errorValue : 'Error - The error value to be used in case of None.
    source : 'T option - The option value.

Returns: Validation<'Error, 'T> The resulting Validation value.

Converts an option to a Validation.

errorValue : 'Error

The error value to be used in case of None.

source : 'T option

The option value.

Returns: Validation<'Error, 'T>

The resulting Validation value.

ofResult x

Full Usage: ofResult x

Parameters:
Returns: Validation<'Error, 'T>

Creates a Validation<'Error,'T> from a Result<'T,'Error>.

x : Result<'T, 'Error>
Returns: Validation<'Error, 'T>

ofValueOptionWith errorValue source

Full Usage: ofValueOptionWith errorValue source

Parameters:
    errorValue : 'Error - The error value to be used in case of None.
    source : 'T voption - The voption value.

Returns: Validation<'Error, 'T> The resulting Validation value.

Converts a voption to a Validation.

errorValue : 'Error

The error value to be used in case of None.

source : 'T voption

The voption value.

Returns: Validation<'Error, 'T>

The resulting Validation value.

partition source

Full Usage: partition source

Parameters:
Returns: 'T list * 'TErrors list A tuple with both resulting lists, Success are in the first list.

Creates two lists by classifying the values depending on whether they were wrapped with Success or Failure.

source : Validation<'TErrors, 'T> list
Returns: 'T list * 'TErrors list

A tuple with both resulting lists, Success are in the first list.

protect unsafeFunction x

Full Usage: protect unsafeFunction x

Parameters:
    unsafeFunction : 'T -> 'U
    x : 'T

Returns: Validation<exn, 'U>

Creates a safe version of the supplied function, which returns a Validation instead of throwing exceptions.

unsafeFunction : 'T -> 'U
x : 'T
Returns: Validation<exn, 'U>

sequence source

Full Usage: sequence source

Parameters:
Returns: ^Functor>
Modifiers: inline

Traverse the Success case.

source : Validation<'Error, ^Functor<'T>>
Returns: ^Functor>

toChoice x

Full Usage: toChoice x

Parameters:
Returns: Choice<'T, 'Error>

Converts a Validation<'Error,'T> to a Choice<'T,'Error>.

x : Validation<'Error, 'T>
Returns: Choice<'T, 'Error>

toResult x

Full Usage: toResult x

Parameters:
Returns: Result<'T, 'Error>

Converts a Validation<'Error,'T> to a Result<'T,'Error>.

x : Validation<'Error, 'T>
Returns: Result<'T, 'Error>

traverse f source

Full Usage: traverse f source

Parameters:
    f : 'T -> ^Functor<'U>
    source : Validation<'Error, 'T>

Returns: ^Functor>
Modifiers: inline
Type parameters: 'T, ^Functor<'U>, ^Functor<Validation<'Error, 'U>>, 'U, 'Error

Traverse the Success case with the supplied function.

f : 'T -> ^Functor<'U>
source : Validation<'Error, 'T>
Returns: ^Functor>

validationNel x

Full Usage: validationNel x

Parameters:
Returns: Validation<NonEmptyList<'TError>, 'T>

validationNel : Result<'a,'e> -> Validation (NonEmptyList<'e>) a This is 'liftError' specialized to 'NonEmptyList', since they are a common semigroup to use.

x : Result<'T, 'TError>
Returns: Validation<NonEmptyList<'TError>, 'T>

zip x y

Full Usage: zip x y

Parameters:
Returns: Validation<^Error, ('T * 'U)>
Modifiers: inline
Type parameters: ^Error, 'T, 'U
x : Validation<^Error, 'T>
y : Validation<^Error, 'U>
Returns: Validation<^Error, ('T * 'U)>