Library with some useful functions on the Maybe
datatype.
Exported Functions: catMaybes, fromJust, fromMaybe, isJust, isNothing, listToMaybe, mapMaybe, maybeToList
Return True
iff the argument is of the form Just _
.
Return True
iff the argument is of the form Nothing
.
Extract the argument from the Just
constructor and throw an error
if the argument is Nothing
.
fromMaybe
:: a -> Maybe a -> a
Extract the argument from the Just
constructor or return the provided
default value if the argument is Nothing
.
listToMaybe
:: [a] -> Maybe a
Return Nothing
on an empty list or Just x
where x
is the first
list element.
maybeToList
:: Maybe a -> [a]
Return an empty list for Nothing
or a singleton list for Just x
.
Return the list of all Just
values.
mapMaybe
:: (a -> Maybe b) -> [a] -> [b]
Apply a function which may throw out elements using the Nothing
constructor to a list of elements.