strict-0.3.2: Strict data types and String IO.

Copyright | (c) 2006-2007 Roman Leshchinskiy
License | BSD-style (see the file LICENSE)
Maintainer | Roman Leshchinskiy <rl@cse.unsw.edu.au>
Stability | experimental
Portability | portable
Safe Haskell | Safe
Language | Haskell98

Data.Strict.Maybe

Description

Strict `Maybe`.

Same as the standard Haskell `Maybe`, but `Just _|_ = _|_`

Note that strict `Maybe` is not a monad since `return _|_ >>= f = _|_` which is not necessarily the same as `f _|_`.

Synopsis

- data Maybe a
  - = Nothing
  - | Just !a
- isJust :: Maybe a -> Bool
- isNothing :: Maybe a -> Bool
- fromJust :: Maybe a -> a
- fromMaybe :: a -> Maybe a -> a
- maybe :: b -> (a -> b) -> Maybe a -> b

# Documentation

data Maybe a Source #

The type of strict optional values.

Constructors

Nothing |
Just !a |

#### Instances

Instances details

Functor Maybe Source # |
Instance details Defined in Data.Strict.Maybe Methods fmap :: (a -> b) -> Maybe a -> Maybe b (<$) :: a -> Maybe b -> Maybe a
Eq a => Eq (Maybe a) Source # |
Instance details Defined in Data.Strict.Maybe Methods (==) :: Maybe a -> Maybe a -> Bool (/=) :: Maybe a -> Maybe a -> Bool
Ord a => Ord (Maybe a) Source # |
Instance details Defined in Data.Strict.Maybe Methods compare :: Maybe a -> Maybe a -> Ordering (<) :: Maybe a -> Maybe a -> Bool (<=) :: Maybe a -> Maybe a -> Bool (>) :: Maybe a -> Maybe a -> Bool (>=) :: Maybe a -> Maybe a -> Bool max :: Maybe a -> Maybe a -> Maybe a min :: Maybe a -> Maybe a -> Maybe a
Read a => Read (Maybe a) Source # |
Instance details Defined in Data.Strict.Maybe Methods readsPrec :: Int -> ReadS (Maybe a) readList :: ReadS [Maybe a] readPrec :: ReadPrec (Maybe a) readListPrec :: ReadPrec [Maybe a]
Show a => Show (Maybe a) Source # |
Instance details Defined in Data.Strict.Maybe Methods showsPrec :: Int -> Maybe a -> ShowS show :: Maybe a -> String showList :: [Maybe a] -> ShowS

isJust :: Maybe a -> Bool Source #

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

isNothing :: Maybe a -> Bool Source #

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.