Validation

0.40.0

Definitions

def ap [etefu] ( v1 : Validation[e, t -> u \ ef] v2 : Validation[e, t] ) : Validation[e, u] \ ef

Source

Applies the function in v1 to the value in v2.

def exists [tefe] ( f : t -> Bool \ ef v : Validation[e, t] ) : Bool \ ef

Source

Returns true if and only if v is Success(t) and f(t) is true.

Returns false if v is Failure.

def forAll [tefe] ( f : t -> Bool \ ef v : Validation[e, t] ) : Bool \ ef

Source

Returns true if v is Success(t) and f(t) is true or if v is Failure.

def getWithDefault [te] ( d : t v : Validation[e, t] ) : t \ Pure

Source

Returns t if v is Success(t). Otherwise returns d.

def map [tefue] ( f : t -> u \ ef v : Validation[e, t] ) : Validation[e, u] \ ef

Source

Returns Success(f(v)) if o is Success(v). Otherwise returns v.

def map10 [t1t2t3t4t5t6t7t8t9t10efue] ( f : t1 -> (t2 -> (t3 -> (t4 -> (t5 -> (t6 -> (t7 -> (t8 -> (t9 -> (t10 -> u \ ef))))))))) v1 : Validation[e, t1] v2 : Validation[e, t2] v3 : Validation[e, t3] v4 : Validation[e, t4] v5 : Validation[e, t5] v6 : Validation[e, t6] v7 : Validation[e, t7] v8 : Validation[e, t8] v9 : Validation[e, t9] v10 : Validation[e, t10] ) : Validation[e, u] \ ef

Source

Applies the 10-ary function f to the values in v1, v2, ... v10.

Returns the concatenation of all the failures as Failure(xs) if any of v1, v2, ... v10 are Failure(xs1).

def map2 [t1t2efue] ( f : t1 -> (t2 -> u \ ef) v1 : Validation[e, t1] v2 : Validation[e, t2] ) : Validation[e, u] \ ef

Source

Applies the binary function f to the values in v1 and v2.

Returns the concatenation of all the failures as Failure(xs) if either or both of v1 or v2 are Failure(xs1).

def map3 [t1t2t3efue] ( f : t1 -> (t2 -> (t3 -> u \ ef)) v1 : Validation[e, t1] v2 : Validation[e, t2] v3 : Validation[e, t3] ) : Validation[e, u] \ ef

Source

Applies the ternary function f to the values in v1, v2 and v3.

Returns the concatenation of all the failures as Failure(xs) if any of v1, v2 and v3 are Failure(xs1).

def map4 [t1t2t3t4efue] ( f : t1 -> (t2 -> (t3 -> (t4 -> u \ ef))) v1 : Validation[e, t1] v2 : Validation[e, t2] v3 : Validation[e, t3] v4 : Validation[e, t4] ) : Validation[e, u] \ ef

Source

Applies the 4-ary function f to the values in v1, v2, v3 and v4.

Returns the concatenation of all the failures as Failure(xs) if any of v1, v2, v3 and v4 are Failure(xs1).

def map5 [t1t2t3t4t5efue] ( f : t1 -> (t2 -> (t3 -> (t4 -> (t5 -> u \ ef)))) v1 : Validation[e, t1] v2 : Validation[e, t2] v3 : Validation[e, t3] v4 : Validation[e, t4] v5 : Validation[e, t5] ) : Validation[e, u] \ ef

Source

Applies the 5-ary function f to the values in v1, v2, ... v5.

Returns the concatenation of all the failures as Failure(xs) if any of v1, v2, ... v5 are Failure(xs1).

def map6 [t1t2t3t4t5t6efue] ( f : t1 -> (t2 -> (t3 -> (t4 -> (t5 -> (t6 -> u \ ef))))) v1 : Validation[e, t1] v2 : Validation[e, t2] v3 : Validation[e, t3] v4 : Validation[e, t4] v5 : Validation[e, t5] v6 : Validation[e, t6] ) : Validation[e, u] \ ef

Source

Applies the 6-ary function f to the values in v1, v2, ... v6.

Returns the concatenation of all the failures as Failure(xs) if any of v1, v2, ... v6 are Failure(xs1).

def map7 [t1t2t3t4t5t6t7efue] ( f : t1 -> (t2 -> (t3 -> (t4 -> (t5 -> (t6 -> (t7 -> u \ ef)))))) v1 : Validation[e, t1] v2 : Validation[e, t2] v3 : Validation[e, t3] v4 : Validation[e, t4] v5 : Validation[e, t5] v6 : Validation[e, t6] v7 : Validation[e, t7] ) : Validation[e, u] \ ef

Source

Applies the 7-ary function f to the values in v1, v2, ... v7.

Returns the concatenation of all the failures as Failure(xs) if any of v1, v2, ... v7 are Failure(xs1).

def map8 [t1t2t3t4t5t6t7t8efue] ( f : t1 -> (t2 -> (t3 -> (t4 -> (t5 -> (t6 -> (t7 -> (t8 -> u \ ef))))))) v1 : Validation[e, t1] v2 : Validation[e, t2] v3 : Validation[e, t3] v4 : Validation[e, t4] v5 : Validation[e, t5] v6 : Validation[e, t6] v7 : Validation[e, t7] v8 : Validation[e, t8] ) : Validation[e, u] \ ef

Source

Applies the 8-ary function f to the values in v1, v2, ... v8.

Returns the concatenation of all the failures as Failure(xs) if any of v1, v2, ... v8 are Failure(xs1).

def map9 [t1t2t3t4t5t6t7t8t9efue] ( f : t1 -> (t2 -> (t3 -> (t4 -> (t5 -> (t6 -> (t7 -> (t8 -> (t9 -> u \ ef)))))))) v1 : Validation[e, t1] v2 : Validation[e, t2] v3 : Validation[e, t3] v4 : Validation[e, t4] v5 : Validation[e, t5] v6 : Validation[e, t6] v7 : Validation[e, t7] v8 : Validation[e, t8] v9 : Validation[e, t9] ) : Validation[e, u] \ ef

Source

Applies the 9-ary function f to the values in v1, v2, ... v9.

Returns the concatenation of all the failures as Failure(xs) if any of v1, v2, ... v9 are Failure(xs1).

def product [et1t2] ( fa : Validation[e, t1] fb : Validation[e, t2] ) : Validation[e, (t1, t2)] \ Pure

Source

Chain two functions, returns the product of their results.

def product3 [et1t2t3] ( fa : Validation[e, t1] fb : Validation[e, t2] fc : Validation[e, t3] ) : Validation[e, (t1, t2, t3)] \ Pure

Source

Chain three functions, returns the product of their results.

def product4 [et1t2t3t4] ( fa : Validation[e, t1] fb : Validation[e, t2] fc : Validation[e, t3] fd : Validation[e, t4] ) : Validation[e, (t1, t2, t3, t4)] \ Pure

Source

Chain four functions, returns the product of their results.

def product5 [et1t2t3t4t5] ( fa : Validation[e, t1] fb : Validation[e, t2] fc : Validation[e, t3] fd : Validation[e, t4] fe : Validation[e, t5] ) : Validation[e, (t1, t2, t3, t4, t5)] \ Pure

Source

Chain five functions, returns the product of their results.

def sequence [et] ( l : List[Validation[e, t]] ) : Validation[e, List[t]] \ Pure

Source

Returns Success(v1 :: v2 :: ... :: vn) if each of l_i is Success(v_i).

Otherwise returns Failure(e1 :: ... :: en) with all of the failures concatenated.

def toList [et] ( v : Validation[e, t] ) : List[t] \ Pure

Source

Converts a Validation to a List.

Returns t :: Nil if v is Success(v). Returns Nil if v is Failure(e).

def toOption [et] ( v : Validation[e, t] ) : Option[t] \ Pure

Source

Converts a Validation to an Option.

Returns Some(t) if v is Success(t). Returns None otherwise.

def toResult [et] ( v : Validation[e, t] ) : Result[Nec[e], t] \ Pure

Source

Converts a Validation to a Result.

Returns Ok(t) if v is Success(t). Returns Err(e) if v is Failure(e).

def traverse [aefeb] ( f : a -> Validation[e, b] \ ef l : List[a] ) : Validation[e, List[b]] \ ef

Source

Returns Success(v1 :: v2 :: ... v :: vn) if each of f(l_i) is Success(v_i).

Otherwise returns Failure(e1 :: ... :: en) with all of the failures concatenated.

def traverseX [aefeb] ( f : a -> Validation[e, b] \ ef l : List[a] ) : Validation[e, Unit] \ ef

Source

Returns Success() if each of f(l_i) is Success(_).

Otherwise returns Failure(e1 :: ... :: en) with all of the failures concatenated.

This function is the "forgetful" version of traverse, use it when the you want the effect of applying f to each element but do not care about collecting the results.

def withDefault [et] ( default : { default = Validation[e, t] } v : Validation[e, t] ) : Validation[e, t] \ Pure

Source

Returns v if it is Success(v). Otherwise returns default.