Either
¶data.either.
Either
¶type Either(α, β) = Left(α) | Right(β)
implements
Applicative(β), Functor(β), Chain(β), Monad(β), ToString
Represents the logical disjunction between α
and β
.
Either.
Left
(value)¶α → Either(α, β)
Constructs a new Either(α, β)
structure holding a
Left
value. This usually represents a failure, due
to the right-bias of this structure.
Either.
Right
(value)¶β → Either(α, β)
Constructs a new Either(α, β)
structure holding a
Right
value. This usually represents a successful
value due to the right bias of this structure.
Either.
of
(value)¶β → Either(α, β)
Creates a new Either(α, β)
instance holding the
Right
value β
.
Either.prototype.
get
()¶Raises: |
|
---|
@Either(α, β) => Unit → β :: throws
Extracts the Right
value out of the Either(α, β)
structure, if it exists.
Either.prototype.
ap
(anApplicative)¶@Either(α, β → γ), f:Applicative(_) => f(β) → f(γ)
Applies the function inside the Either(α, β)
structure
to another Applicative type.
Either.prototype.
map
(transformation)¶@Either(α, β) => (β → γ) → Either(α, γ)
Transforms the Right
value of the Either(α, β)
structure
using a regular unary function.
Either.prototype.
chain
(transformation)¶@Either(α, β), m:Monad(_) => (β → m(γ)) → m(γ)
Transforms the Right
value of the Either(α, β)
structure
using an unary function over monads.
Either.prototype.
fold
(leftTransformation, rightTransformation)¶@Either(α, β) => (α → γ), (β → γ) → γ
Applies a function to each case in the data structure.
Either.prototype.
cata
(pattern)¶@Either(α, β) => { r | Pattern } → γ
type Pattern {
Left: α → γ,
Right: β → γ
}
Applies a function to each case in the data structure.
Either.prototype.
swap
()¶@Either(α, β) => Unit → Either(β, α)
Swaps the disjunction values.
Either.prototype.
bimap
(leftTransformation, rightTransformation)¶@Either(α, β) => (α → γ), (β → δ) → Either(γ, δ)
Maps both sides of the disjunction.