hask.Data.Maybe – The Data.Maybe

hask.Data.Maybe.Maybe

The ADT Maybe:

data.Maybe("a") == d.Nothing | d.Just("a") & deriving(Read, Show, Eq, Ord)
hask.Data.Maybe.Nothing
hask.Data.Maybe.Just(a)
hask.Data.Maybe.in_maybe(fn)[source]

Decorator for monadic error handling.

If the decorated function raises an exception, return Nothing. Otherwise, take the result and wrap it in a Just.

hask.Data.Maybe.maybe(*args, **kwargs)

maybe :: b -> (a -> b) -> Maybe a -> b

The maybe function takes a default value, a function, and a Maybe value. If the Maybe value is Nothing, the function returns the default value. Otherwise, it applies the function to the value inside the Just and returns the result.

hask.Data.Maybe.isJust(*args, **kwargs)

isJust :: [Maybe a] -> bool

hask.Data.Maybe.isNothing(*args, **kwargs)

isNothing :: [Maybe a] -> bool

hask.Data.Maybe.fromJust(*args, **kwargs)

fromJust :: [Maybe a] -> a

hask.Data.Maybe.listToMaybe(*args, **kwargs)

listToMaybe :: [a] -> [Maybe a]

hask.Data.Maybe.maybeToList(*args, **kwargs)

maybeToList :: Maybe a -> [a]

The maybeToList function returns an empty list when given Nothing or a singleton list when not given Nothing.

hask.Data.Maybe.catMaybes(*args, **kwargs)

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

The catMaybes function takes a list of Maybes and returns a list of all the Just values.

hask.Data.Maybe.mapMaybe(*args, **kwargs)

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

The mapMaybe function is a version of map which can throw out elements. In particular, the functional argument returns something of type Maybe b. If this is Nothing, no element is added on to the result list. If it is Just b, then b is included in the result list.