ghc-7.10.2: The GHC API

Safe Haskell | Safe
Language | Haskell2010

Maybes

Synopsis

- module Data.Maybe
- data MaybeErr err val
  - = Succeeded val
  - | Failed err
- failME :: err -> MaybeErr err val
- isSuccess :: MaybeErr err val -> Bool
- orElse :: Maybe a -> a -> a
- firstJust :: Maybe a -> Maybe a -> Maybe a
- firstJusts :: [Maybe a] -> Maybe a
- whenIsJust :: Monad m => Maybe a -> (a -> m ()) -> m ()
- expectJust :: String -> Maybe a -> a
- newtype MaybeT m a = MaybeT {
  - runMaybeT :: m (Maybe a)
  }
- liftMaybeT :: Monad m => m a -> MaybeT m a

# Documentation

module Data.Maybe

data MaybeErr err val Source

Constructors

Succeeded val |
Failed err |

Instances

Monad (MaybeErr err) |
Functor (MaybeErr err) |
Applicative (MaybeErr err) |

failME :: err -> MaybeErr err val Source

isSuccess :: MaybeErr err val -> Bool Source

orElse :: Maybe a -> a -> a infixr 4 Source

Flipped version of `fromMaybe`, useful for chaining.

firstJust :: Maybe a -> Maybe a -> Maybe a Source

firstJusts :: [Maybe a] -> Maybe a Source

Takes a list of `Maybes` and returns the first `Just` if there is one, or `Nothing` otherwise.

whenIsJust :: Monad m => Maybe a -> (a -> m ()) -> m () Source

expectJust :: String -> Maybe a -> a Source

newtype MaybeT m a Source

Constructors

MaybeT |
Fields runMaybeT :: m (Maybe a)

Instances

Monad m => Monad (MaybeT m) |
Functor m => Functor (MaybeT m) |
(Monad m, Functor m) => Applicative (MaybeT m) |
Monad m => Alternative (MaybeT m) |
Monad m => MonadPlus (MaybeT m) |

liftMaybeT :: Monad m => m a -> MaybeT m a Source