fay-base-0.19.4: The base package for Fay.

Safe HaskellNone

Data.Maybe

Contents

Description

Maybe functions.

Synopsis

General operations from base

isJust :: Maybe a -> BoolSource

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

isNothing :: Maybe a -> BoolSource

The isNothing function returns True iff its argument is Nothing.

fromJust :: Maybe a -> aSource

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

fromMaybe :: a -> Maybe a -> aSource

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 aSource

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 -> rSource

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 bSource

Basically fmap for Maybe.

joinMaybe :: Maybe (Maybe a) -> Maybe aSource

Join for Maybe.