You can think of this like a short-circuiting logical "and" operation on a
Maybe type. If maybe is just, then the result is the
andMaybe. If maybe is Nothing, the result is Nothing.
This is useful when you have another Maybe value you want to provide if and
only if you have a Just – that is, when you need to make sure that if you
Nothing, whatever else you're handing a Maybe to also gets a Nothing.
Notice that, unlike in map or its variants, the original maybe is
not involved in constructing the new Maybe.
You can think of this like a short-circuiting logical "and" operation on a
Maybe
type. Ifmaybe
isjust
, then the result is theandMaybe
. Ifmaybe
isNothing
, the result isNothing
.This is useful when you have another
Maybe
value you want to provide if and only if you have aJust
– that is, when you need to make sure that if youNothing
, whatever else you're handing aMaybe
to also gets aNothing
.Notice that, unlike in
map
or its variants, the originalmaybe
is not involved in constructing the newMaybe
.Examples