Library with some useful functions on the Maybe
datatype.
Author: Frank Huch, Bernd Brassel, Bjoern Peemoeller
Version: October 2014
isJust
:: Maybe a -> Bool
Return True
iff the argument is of the form Just _ .
|
isNothing
:: Maybe a -> Bool
Return True
iff the argument is of the form Nothing .
|
fromJust
:: Maybe a -> a
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 .
|
catMaybes
:: [Maybe a] -> [a]
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.
|
Return
|
Return
|
Extract the argument from the |
Extract the argument from the
|
Return
|
Return an empty list for
|
Return the list of all |
Apply a function which may throw out elements using the |