Copyright  (C) Edward Kmett 20132015 (c) Google Inc. 2012 

License  BSDstyle (see the file LICENSE) 
Maintainer  Edward Kmett <ekmett@gmail.com> 
Stability  experimental 
Portability  nonportable 
Safe Haskell  Trustworthy 
Language  Haskell98 
Synopsis
 newtype CatchT m a = CatchT {
 runCatchT :: m (Either SomeException a)
 type Catch = CatchT Identity
 runCatch :: Catch a > Either SomeException a
 mapCatchT :: (m (Either SomeException a) > n (Either SomeException b)) > CatchT m a > CatchT n b
 module Control.Monad.Catch
Transformer
The transformers
style monad transfomer
Add Exception
handling abilities to a Monad
.
This should never be used in combination with IO
. Think of CatchT
as an alternative base monad for use with mocking code that solely throws
exceptions via throwM
.
Note: that IO
monad has these abilities already, so stacking CatchT
on top
of it does not add any value and can possibly be confusing:
>>>
(error "Hello!" :: IO ()) `catch` (\(e :: ErrorCall) > liftIO $ print e)
Hello!
>>>
runCatchT $ (error "Hello!" :: CatchT IO ()) `catch` (\(e :: ErrorCall) > liftIO $ print e)
*** Exception: Hello!
>>>
runCatchT $ (throwM (ErrorCall "Hello!") :: CatchT IO ()) `catch` (\(e :: ErrorCall) > liftIO $ print e)
Hello!
CatchT  

Instances
MonadTrans CatchT Source #  
Defined in Control.Monad.Catch.Pure  
MonadRWS r w s m => MonadRWS r w s (CatchT m) Source #  
Defined in Control.Monad.Catch.Pure  
MonadWriter w m => MonadWriter w (CatchT m) Source #  
MonadState s m => MonadState s (CatchT m) Source #  
MonadReader e m => MonadReader e (CatchT m) Source #  
Monad m => Monad (CatchT m) Source #  
Monad m => Functor (CatchT m) Source #  
MonadFix m => MonadFix (CatchT m) Source #  
Defined in Control.Monad.Catch.Pure  
Monad m => Applicative (CatchT m) Source #  
Foldable m => Foldable (CatchT m) Source #  
Defined in Control.Monad.Catch.Pure fold :: Monoid m0 => CatchT m m0 > m0 # foldMap :: Monoid m0 => (a > m0) > CatchT m a > m0 # foldr :: (a > b > b) > b > CatchT m a > b # foldr' :: (a > b > b) > b > CatchT m a > b # foldl :: (b > a > b) > b > CatchT m a > b # foldl' :: (b > a > b) > b > CatchT m a > b # foldr1 :: (a > a > a) > CatchT m a > a # foldl1 :: (a > a > a) > CatchT m a > a # elem :: Eq a => a > CatchT m a > Bool # maximum :: Ord a => CatchT m a > a # minimum :: Ord a => CatchT m a > a #  
(Monad m, Traversable m) => Traversable (CatchT m) Source #  
MonadIO m => MonadIO (CatchT m) Source #  
Defined in Control.Monad.Catch.Pure  
Monad m => Alternative (CatchT m) Source #  
Monad m => MonadPlus (CatchT m) Source #  
Monad m => MonadMask (CatchT m) Source #  Note: This instance is only valid if the underlying monad has a single exit point! For example, 
Defined in Control.Monad.Catch.Pure  
Monad m => MonadCatch (CatchT m) Source #  
Monad m => MonadThrow (CatchT m) Source #  
mapCatchT :: (m (Either SomeException a) > n (Either SomeException b)) > CatchT m a > CatchT n b Source #
Typeclass
The mtl style typeclass
module Control.Monad.Catch