strict-base-types-0.4.0: Strict variants of the types provided in base.

Copyright(c) 2006-2007 Roman Leshchinskiy (c) 2013 Simon Meier
LicenseBSD-style (see the file LICENSE)
MaintainerSimon Meier <iridcode@gmail.com>
Stabilityexperimental
PortabilityGHC
Safe HaskellNone
LanguageHaskell98

Data.Maybe.Strict

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 :: * -> *

The type of strict optional values.

Constructors

Nothing 
Just !a 

Instances

Functor Maybe 
Eq a => Eq (Maybe a) 
Ord a => Ord (Maybe a) 
Read a => Read (Maybe a) 
Show a => Show (Maybe a) 
type Rep (Maybe a) 

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

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.

isJust :: Maybe a -> Bool

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

isNothing :: Maybe a -> Bool

Yields True iff the argument is Nothing.

fromJust :: Maybe a -> a

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

fromMaybe :: a -> Maybe a -> a

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.

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.

_Just :: Prism (Maybe a) (Maybe b) a b Source

Analogous to _Just in Control.Lens.Prism