An optional value
A Maybe[A]
will either be a wrapped A
instance (Just[A]
), or a lack of underlying
A
instance (Empty[A]
).
Maybe[A]
is isomorphic to Option[A]
, however there are some differences between
the two. Maybe
is invariant in A
while Option
is covariant. Maybe[A]
does not expose
an unsafe get
operation to access the underlying A
value (that may not exist) like
Option[A]
does. Maybe[A]
does not come with an implicit conversion to Iterable[A]
(a
trait with over a dozen super types).
- Companion
- object
Value members
Concrete methods
Catamorphism. Run the given function on the underlying value if present, otherwise return the provided fallback value
Catamorphism. Run the given function on the underlying value if present, otherwise return the provided fallback value
Return true
if this is a Maybe.Just and the underlying value
satisfies the provided predicate
Return true
if this is a Maybe.Just and the underlying value
satisfies the provided predicate
Return true
if this is a Maybe.Empty or if this is a Maybe.Just
and the underlying value satisfies the provided predicate
Return true
if this is a Maybe.Empty or if this is a Maybe.Just
and the underlying value satisfies the provided predicate
Return the underlying value if present, otherwise the provided fallback value
Return the underlying value if present, otherwise the provided fallback value
Return this instance if it is a Maybe.Just, otherwise the provided fallback
Return this instance if it is a Maybe.Just, otherwise the provided fallback
Return the underlying value wrapped in type F
if present, otherwise the
empty value for type F
Return the underlying value wrapped in type F
if present, otherwise the
empty value for type F
Return the underlying value if present, otherwise the monoid zero
Return the underlying value if present, otherwise the monoid zero
Turn the underlying value into a failure validation if present, otherwise return a success validation with the provided fallback value
Turn the underlying value into a failure validation if present, otherwise return a success validation with the provided fallback value
Turn the underlying value into a left disjunction if present, otherwise return a right disjunction with the provided fallback value
Turn the underlying value into a left disjunction if present, otherwise return a right disjunction with the provided fallback value
Turn the underlying value into a right disjunction if present, otherwise return a left disjunction with the provided fallback value
Turn the underlying value into a right disjunction if present, otherwise return a left disjunction with the provided fallback value