ghc-8.2.1: The GHC API

Safe HaskellNone
LanguageHaskell2010

Maybes

Contents

Synopsis

Documentation

module Data.Maybe

data MaybeErr err val Source #

Constructors

Succeeded val 
Failed err 

Instances

Monad (MaybeErr err) Source # 

Methods

(>>=) :: MaybeErr err a -> (a -> MaybeErr err b) -> MaybeErr err b #

(>>) :: MaybeErr err a -> MaybeErr err b -> MaybeErr err b #

return :: a -> MaybeErr err a #

fail :: String -> MaybeErr err a #

Functor (MaybeErr err) Source # 

Methods

fmap :: (a -> b) -> MaybeErr err a -> MaybeErr err b #

(<$) :: a -> MaybeErr err b -> MaybeErr err a #

Applicative (MaybeErr err) Source # 

Methods

pure :: a -> MaybeErr err a #

(<*>) :: MaybeErr err (a -> b) -> MaybeErr err a -> MaybeErr err b #

liftA2 :: (a -> b -> c) -> MaybeErr err a -> MaybeErr err b -> MaybeErr err c #

(*>) :: MaybeErr err a -> MaybeErr err b -> MaybeErr err b #

(<*) :: MaybeErr err a -> MaybeErr err b -> MaybeErr err a #

failME :: err -> MaybeErr err val Source #

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

Flipped version of fromMaybe, useful for chaining.

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 #

MaybeT

newtype MaybeT (m :: * -> *) a :: (* -> *) -> * -> * #

The parameterizable maybe monad, obtained by composing an arbitrary monad with the Maybe monad.

Computations are actions that may produce a value or exit.

The return function yields a computation that produces that value, while >>= sequences two subcomputations, exiting if either computation does.

Constructors

MaybeT 

Fields

Instances

MonadTrans MaybeT 

Methods

lift :: Monad m => m a -> MaybeT m a #

Monad m => Monad (MaybeT m) 

Methods

(>>=) :: MaybeT m a -> (a -> MaybeT m b) -> MaybeT m b #

(>>) :: MaybeT m a -> MaybeT m b -> MaybeT m b #

return :: a -> MaybeT m a #

fail :: String -> MaybeT m a #

Functor m => Functor (MaybeT m) 

Methods

fmap :: (a -> b) -> MaybeT m a -> MaybeT m b #

(<$) :: a -> MaybeT m b -> MaybeT m a #

MonadFix m => MonadFix (MaybeT m) 

Methods

mfix :: (a -> MaybeT m a) -> MaybeT m a #

Monad m => MonadFail (MaybeT m) 

Methods

fail :: String -> MaybeT m a #

(Functor m, Monad m) => Applicative (MaybeT m) 

Methods

pure :: a -> MaybeT m a #

(<*>) :: MaybeT m (a -> b) -> MaybeT m a -> MaybeT m b #

liftA2 :: (a -> b -> c) -> MaybeT m a -> MaybeT m b -> MaybeT m c #

(*>) :: MaybeT m a -> MaybeT m b -> MaybeT m b #

(<*) :: MaybeT m a -> MaybeT m b -> MaybeT m a #

Foldable f => Foldable (MaybeT f) 

Methods

fold :: Monoid m => MaybeT f m -> m #

foldMap :: Monoid m => (a -> m) -> MaybeT f a -> m #

foldr :: (a -> b -> b) -> b -> MaybeT f a -> b #

foldr' :: (a -> b -> b) -> b -> MaybeT f a -> b #

foldl :: (b -> a -> b) -> b -> MaybeT f a -> b #

foldl' :: (b -> a -> b) -> b -> MaybeT f a -> b #

foldr1 :: (a -> a -> a) -> MaybeT f a -> a #

foldl1 :: (a -> a -> a) -> MaybeT f a -> a #

toList :: MaybeT f a -> [a] #

null :: MaybeT f a -> Bool #

length :: MaybeT f a -> Int #

elem :: Eq a => a -> MaybeT f a -> Bool #

maximum :: Ord a => MaybeT f a -> a #

minimum :: Ord a => MaybeT f a -> a #

sum :: Num a => MaybeT f a -> a #

product :: Num a => MaybeT f a -> a #

Traversable f => Traversable (MaybeT f) 

Methods

traverse :: Applicative f => (a -> f b) -> MaybeT f a -> f (MaybeT f b) #

sequenceA :: Applicative f => MaybeT f (f a) -> f (MaybeT f a) #

mapM :: Monad m => (a -> m b) -> MaybeT f a -> m (MaybeT f b) #

sequence :: Monad m => MaybeT f (m a) -> m (MaybeT f a) #

Eq1 m => Eq1 (MaybeT m) 

Methods

liftEq :: (a -> b -> Bool) -> MaybeT m a -> MaybeT m b -> Bool #

Ord1 m => Ord1 (MaybeT m) 

Methods

liftCompare :: (a -> b -> Ordering) -> MaybeT m a -> MaybeT m b -> Ordering #

Read1 m => Read1 (MaybeT m) 

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (MaybeT m a) #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [MaybeT m a] #

liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (MaybeT m a) #

liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [MaybeT m a] #

Show1 m => Show1 (MaybeT m) 

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> MaybeT m a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [MaybeT m a] -> ShowS #

MonadZip m => MonadZip (MaybeT m) 

Methods

mzip :: MaybeT m a -> MaybeT m b -> MaybeT m (a, b) #

mzipWith :: (a -> b -> c) -> MaybeT m a -> MaybeT m b -> MaybeT m c #

munzip :: MaybeT m (a, b) -> (MaybeT m a, MaybeT m b) #

MonadIO m => MonadIO (MaybeT m) 

Methods

liftIO :: IO a -> MaybeT m a #

(Functor m, Monad m) => Alternative (MaybeT m) 

Methods

empty :: MaybeT m a #

(<|>) :: MaybeT m a -> MaybeT m a -> MaybeT m a #

some :: MaybeT m a -> MaybeT m [a] #

many :: MaybeT m a -> MaybeT m [a] #

Monad m => MonadPlus (MaybeT m) 

Methods

mzero :: MaybeT m a #

mplus :: MaybeT m a -> MaybeT m a -> MaybeT m a #

(Monad m, HasDynFlags m) => HasDynFlags (MaybeT m) Source # 
(Eq1 m, Eq a) => Eq (MaybeT m a) 

Methods

(==) :: MaybeT m a -> MaybeT m a -> Bool #

(/=) :: MaybeT m a -> MaybeT m a -> Bool #

(Ord1 m, Ord a) => Ord (MaybeT m a) 

Methods

compare :: MaybeT m a -> MaybeT m a -> Ordering #

(<) :: MaybeT m a -> MaybeT m a -> Bool #

(<=) :: MaybeT m a -> MaybeT m a -> Bool #

(>) :: MaybeT m a -> MaybeT m a -> Bool #

(>=) :: MaybeT m a -> MaybeT m a -> Bool #

max :: MaybeT m a -> MaybeT m a -> MaybeT m a #

min :: MaybeT m a -> MaybeT m a -> MaybeT m a #

(Read1 m, Read a) => Read (MaybeT m a) 
(Show1 m, Show a) => Show (MaybeT m a) 

Methods

showsPrec :: Int -> MaybeT m a -> ShowS #

show :: MaybeT m a -> String #

showList :: [MaybeT m a] -> ShowS #

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

tryMaybeT :: IO a -> MaybeT IO a Source #

Try performing an IO action, failing on error.