ghc-7.8.4: The GHC API

Safe Haskell | Safe-Inferred
Language | Haskell98

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
- mapCatMaybes :: (a -> Maybe b) -> [a] -> [b]
- allMaybes :: [Maybe a] -> Maybe [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
- maybeToBool :: Maybe a -> Bool
- newtype MaybeT m a = MaybeT {
  - runMaybeT :: m (Maybe a)
  }

# Documentation

module Data.Maybe

data MaybeErr err val

Constructors

Succeeded val |
Failed err |

Instances

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

failME :: err -> MaybeErr err val

isSuccess :: MaybeErr err val -> Bool

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

flipped version of `fromMaybe`.

mapCatMaybes :: (a -> Maybe b) -> [a] -> [b]

allMaybes :: [Maybe a] -> Maybe [a]

Collects a list of `Justs` into a single `Just`, returning `Nothing` if there are any `Nothings`.

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

firstJusts :: [Maybe a] -> Maybe a

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 ()

expectJust :: String -> Maybe a -> a

maybeToBool :: Maybe a -> Bool

newtype MaybeT m a

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) |