| Copyright | (C) Edward Kmett 2013-2015 (c) Google Inc. 2012 |
|---|---|
| License | BSD-style (see the file LICENSE) |
| Maintainer | Edward Kmett <ekmett@gmail.com> |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | Trustworthy |
| Language | Haskell2010 |
Control.Monad.Catch.Pure
Contents
Description
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!
Constructors
| CatchT | |
Fields
| |
Instances
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