Maybe
¶data.maybe.
Maybe
¶type Maybe(α) = Nothing | Just(α)
implements
Applicative(α), Functor(α), Chain(α), Monad(α), ToString
A structure for values that may not be present, or computations that may fail.
Maybe.
Nothing
()¶Unit → Maybe(α)
Constructs a new Maybe(α)
structure with an absent value.
Commonly used to represent a failure.
Maybe.
Just
(value)¶α → Maybe(α)
Constructs a new Maybe(α)
structure that holds the single
value α
. Commonly used to represent a success.
Maybe.
of
(value)¶α → Maybe(α)
Constructs a new Maybe(α)
structure that holds the single
value α
.
Maybe.
fromNullable
(value)¶α | null | undefined → Maybe(α)
Constructs a new Maybe(α)
value from a nullable type.
If the value is null
or undefined
, returns a Nothing
,
otherwise returns the value wrapped in a Just
.
Maybe.prototype.
ap
(anApplicative)¶@Maybe(α → β), f:Applicative(_) => f(α) → f(β)
Applies the function inside the structure to another Applicative type.
Maybe.prototype.
map
(transformation)¶@Maybe(α) => (α → β) → Maybe(β)
Transforms the value of this structure using a regular unary function.
Maybe.prototype.
chain
(transformation)¶@Maybe(α), m:Monad(_) => (α → m(β)) → m(β)
Transforms the value of this structure using an unary function over monads.