Module Data.Maybe

Library with some useful functions on the Maybe datatype.

Category
general
Author
Frank Huch, Bernd Brassel, Bjoern Peemoeller
Version
October 2014

Exported Functions: catMaybes, fromJust, fromMaybe, isJust, isNothing, listToMaybe, mapMaybe, maybeToList


Exported Functions


isJust :: Maybe a -> Bool  Deterministic 

Return True iff the argument is of the form Just _.

Further infos:
  • solution complete, i.e., able to compute all solutions

isNothing :: Maybe a -> Bool  Deterministic 

Return True iff the argument is of the form Nothing.

Further infos:
  • solution complete, i.e., able to compute all solutions

fromJust :: Maybe a -> a  Deterministic 

Extract the argument from the Just constructor and throw an error if the argument is Nothing.


fromMaybe :: a -> Maybe a -> a  Deterministic 

Extract the argument from the Just constructor or return the provided default value if the argument is Nothing.

Further infos:
  • solution complete, i.e., able to compute all solutions

listToMaybe :: [a] -> Maybe a  Deterministic 

Return Nothing on an empty list or Just x where x is the first list element.

Further infos:
  • solution complete, i.e., able to compute all solutions

maybeToList :: Maybe a -> [a]  Deterministic 

Return an empty list for Nothing or a singleton list for Just x.

Further infos:
  • solution complete, i.e., able to compute all solutions

catMaybes :: [Maybe a] -> [a]  Deterministic 

Return the list of all Just values.


mapMaybe :: (a -> Maybe b) -> [a] -> [b]  Deterministic 

Apply a function which may throw out elements using the Nothing constructor to a list of elements.