Data.Maybe

| Haskell Core Libraries (base package) | Parent | Contents | Index
Data.Maybe |
Portability | portable
Stability | experimental
Maintainer | libraries@haskell.org
Description
The Maybe type, and associated operations.
Synopsis
data Maybe a
= Nothing
| Just a
maybe :: b -> (a -> b) -> Maybe a -> b
isJust :: Maybe a -> Bool
isNothing :: Maybe a -> Bool
fromJust :: Maybe a -> a
fromMaybe :: a -> Maybe a -> a
listToMaybe :: [a] -> Maybe a
maybeToList :: Maybe a -> [a]
catMaybes :: [Maybe a] -> [a]
mapMaybe :: (a -> Maybe b) -> [a] -> [b]
Documentation
data Maybe a
The `Maybe` type encapsulates an optional value. A value of type ``Maybe` a` either contains a value of type `a` (represented as ``Just` a`), or it is empty (represented as `Nothing`). Using `Maybe` is a good way to deal with errors or exceptional cases without resorting to drastic measures such as `error`. The `Maybe` type is also a monad. It is a simple kind of error monad, where all errors are represented by `Nothing`. A richer error monad can be built using the `Either` type.
Constructors
Nothing |
Just a |
Instances
MonadPlus Maybe
MonadFix Maybe
(Typeable a) => Typeable (Maybe a)
Functor Maybe
Monad Maybe
(Read a) => Read (Maybe a)
(Show a) => Show (Maybe a)
maybe :: b -> (a -> b) -> Maybe a -> b
isJust :: Maybe a -> Bool
isNothing :: Maybe a -> Bool
fromJust :: Maybe a -> a
fromMaybe :: a -> Maybe a -> a
listToMaybe :: [a] -> Maybe a
maybeToList :: Maybe a -> [a]
catMaybes :: [Maybe a] -> [a]
mapMaybe :: (a -> Maybe b) -> [a] -> [b]
Produced by Haddock version 0.4