Validation¶data.validation.Validation¶type Validation(α, β) = Failure(α) | Success(β)
implements
Applicative(β), Functor(β), ToString
Represents the logical disjunction between α and β.
Validation.prototype.isFailure¶Boolean
True if the Validation(α, β) contains a Failure value.
Validation.Failure(value)¶α → Validation(α, β)
Constructs a new Validation structure holding a
Failure value.
Validation.Success(value)¶β → Validation(α, β)
Constructs a new Validation structure holding a
Success value.
Validation.of(value)¶β → Validation(α, β)
Creates a new Validation instance holding the
Success value β.
Validation.prototype.get()¶| Raises: |
|
|---|
@Validation(α, β) => Unit → β :: throws
Extracts the Success value out of the Validation(α, β)
structure, if it exists.
Validation.prototype.ap(anApplicative)¶@Validation(α, β → γ), f:Applicative(_) => f(β) → f(γ)
Applies the function inside the Validation(α, β) structure
to another Applicative type, and combines failures
with a semigroup.
Validation.prototype.map(transformation)¶@Validation(α, β) => (β → γ) → Validation(α, γ)
Transforms the Success value of the Validation(α, β)
structure using a regular unary function.
Validation.prototype.fold(leftTransformation, rightTransformation)¶@Validation(α, β) => (α → γ), (β → γ) → γ
Applies a function to each case in the data structure.
Validation.prototype.cata(pattern)¶@Validation(α, β) => { r | Pattern } → γ
type Pattern {
Failure: α → γ,
Success: β → γ
}
Applies a function to each case in the data structure.
Validation.prototype.swap()¶@Validation(α, β) => Unit → Validation(β, α)
Swaps the disjunction values.
Validation.prototype.bimap(leftTransformation, rightTransformation)¶@Validation(α, β) => (α → γ), (β → δ) → Validation(γ, δ)
Maps both sides of the disjunction.