MaybeT -package:relude
The parameterizable maybe monad, a strict monad obtained by composing
an arbitrary monad with the
Maybe monad.
Computations are actions that may produce a value or exit.
The
return function yields a computation that produces that
value, while
>>= sequences two subcomputations, exiting
if either computation does.
The parameterizable maybe monad, obtained by composing an arbitrary
monad with the
Maybe monad.
Computations are actions that may produce a value or exit.
The
return function yields a computation that produces that
value, while
>>= sequences two subcomputations, exiting
if either computation does.
Not on Stackage, so not searched.
MaybeT monad transformer
The parameterizable maybe monad, obtained by composing an arbitrary
monad with the
Maybe monad.
Computations are actions that may produce a value or exit.
The
return function yields a computation that produces that
value, while
>>= sequences two subcomputations, exiting
if either computation does.
Case analysis for
MaybeT
Use the first argument if the
MaybeT computation fails,
otherwise apply the function to the successful result.
Embed in the
Maybe monad.
Not on Stackage, so not searched.
MaybeT monad transformer using transformers instead of mtl.
MaybeTable t is the table t, but as the result of an
outer join. If the outer join fails to match any rows, this is
essentialy Nothing, and if the outer join does match rows,
this is like Just. Unfortunately, SQL makes it impossible to
distinguish whether or not an outer join matched any rows based
generally on the row contents - if you were to join a row entirely of
nulls, you can't distinguish if you matched an all null row, or if the
match failed. For this reason MaybeTable contains an extra
field - a "nullTag" - to track whether or not the outer join produced
any rows.
Not on Stackage, so not searched.
MaybeT monad transformer compatible with monads-tf (deprecated)
The
maybeToList function returns an empty list when given
Nothing or a singleton list when given
Just.
Examples
Basic usage:
>>> maybeToList (Just 7)
[7]
>>> maybeToList Nothing
[]
One can use
maybeToList to avoid pattern matching when combined
with a function that (safely) works on lists:
>>> import GHC.Internal.Text.Read ( readMaybe )
>>> sum $ maybeToList (readMaybe "3")
3
>>> sum $ maybeToList (readMaybe "")
0
Convert a
MaybeT computation to
ExceptT, with a default
exception value.
As
timeoutImprovingIO, but don't bother applying a timeout to
the action if
Nothing is given as the number of microseconds
to apply the time out for.
Given a
Maybe, convert it to an
Either, providing a
suitable value for the
Left should the value be
Nothing.
\a b -> maybeToEither a (Just b) == Right b
\a -> maybeToEither a Nothing == Left a