fay-base-0.21.2.0: The base package for Fay.
Safe HaskellNone
LanguageHaskell2010

Data.Maybe

Description

Maybe functions.

Synopsis

General operations from base

isJust :: Maybe a -> Bool Source #

The isJust function returns True iff its argument is of the form Just _.

isNothing :: Maybe a -> Bool Source #

The isNothing function returns True iff its argument is Nothing.

fromJust :: Maybe a -> a Source #

The fromJust function extracts the element out of a Just and throws an error if its argument is Nothing.

fromMaybe :: a -> Maybe a -> a Source #

The fromMaybe function takes a default value and and Maybe value. If the Maybe is Nothing, it returns the default values; otherwise, it returns the value contained in the Maybe.

maybeToList :: Maybe a -> [a] Source #

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

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

The listToMaybe function returns Nothing on an empty list or Just a where a is the first element of the list.

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

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

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

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 just Just b, then b is included in the result list.

mapMaybeFB :: (b -> r -> r) -> (a -> Maybe b) -> a -> r -> r Source #

Fay helpers

whenJust :: Maybe a -> (a -> Fay ()) -> Fay () Source #

Handy alternative to not having forM.

whenJust' :: Maybe a -> (a -> Fay b) -> Fay (Maybe b) Source #

Similar to forM again.

onJust :: (a -> b) -> Maybe a -> Maybe b Source #

Basically fmap for Maybe.

joinMaybe :: Maybe (Maybe a) -> Maybe a Source #

Join for Maybe.