strict-0.4.0.1: Strict data types and String IO.

Data.Strict.Maybe

Description

The strict variant of the standard Haskell Maybe type and the corresponding variants of the functions from Data.Maybe.

Note that in contrast to the standard lazy Maybe type, the strict Maybe type is not an applicative functor, and therefore also not a monad. The problem is the homomorphism law, which states that

pure f <*> pure x = pure (f x)  -- must hold for all f

This law does not hold for the expected applicative functor instance of Maybe, as this instance does not satisfy pure f <*> pure _|_ = pure (f _|_) for f = const.

Synopsis

# Documentation

data Maybe a Source #

The type of strict optional values.

Constructors

 Nothing Just !a

#### Instances

Instances details

isJust :: Maybe a -> Bool Source #

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

Yields True iff the argument is Nothing.

fromJust :: Maybe a -> a Source #

Extracts the element out of a Just and throws an error if the argument is Nothing.

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

Given a default value and a Maybe, yield the default value if the Maybe argument is Nothing and extract the value out of the Just otherwise.

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

Given a default value, a function and a Maybe value, yields the default value if the Maybe value is Nothing and applies the function to the value stored in the Just otherwise.

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

Analogous to listToMaybe in Data.Maybe.

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

Analogous to maybeToList in Data.Maybe.

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

Analogous to catMaybes in Data.Maybe.

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

Analogous to mapMaybe in Data.Maybe.