dataprep/validated
Types
Applicative functor for error accumulation.
pub type Validated(a, e) {
Valid(a)
Invalid(non_empty_list.NonEmptyList(e))
}
Constructors
-
Valid(a) -
Invalid(non_empty_list.NonEmptyList(e))
Values
pub fn and_then(
v: Validated(a, e),
f: fn(a) -> Validated(b, e),
) -> Validated(b, e)
Monadic bind. Sequential, short-circuits on error. Use for dependent operations (e.g. parse then validate). Does NOT accumulate errors – that is intentional.
pub fn map(v: Validated(a, e), f: fn(a) -> b) -> Validated(b, e)
Transform the success value (functor map).
pub fn map2(
f: fn(a, b) -> c,
va: Validated(a, e),
vb: Validated(b, e),
) -> Validated(c, e)
Combine two Validated values, accumulating all errors.
pub fn map3(
f: fn(a, b, c) -> d,
va: Validated(a, e),
vb: Validated(b, e),
vc: Validated(c, e),
) -> Validated(d, e)
Combine three Validated values, accumulating all errors.
pub fn map4(
f: fn(a, b, c, d) -> out,
va: Validated(a, e),
vb: Validated(b, e),
vc: Validated(c, e),
vd: Validated(d, e),
) -> Validated(out, e)
Combine four Validated values, accumulating all errors.
pub fn map5(
f: fn(a, b, c, d, e_) -> out,
va: Validated(a, e),
vb: Validated(b, e),
vc: Validated(c, e),
vd: Validated(d, e),
ve: Validated(e_, e),
) -> Validated(out, e)
Combine five Validated values, accumulating all errors.