exception-transformers-0.4.0.8: Type classes and monads for unchecked extensible exceptions.
Copyright(c) Harvard University 2008-2011
(c) Geoffrey Mainland 2011-2016
LicenseBSD-style
Maintainermainland@cs.drexel.edu
Safe HaskellNone
LanguageHaskell98

Control.Monad.Exception

Description

 
Synopsis

Documentation

class (Typeable e, Show e) => Exception e where #

Minimal complete definition

Nothing

Methods

toException :: e -> SomeException #

fromException :: SomeException -> Maybe e #

displayException :: e -> String #

Instances

Instances details
Exception NestedAtomically 
Instance details

Defined in Control.Exception.Base

Methods

toException :: NestedAtomically -> SomeException #

fromException :: SomeException -> Maybe NestedAtomically #

displayException :: NestedAtomically -> String #

Exception NoMethodError 
Instance details

Defined in Control.Exception.Base

Methods

toException :: NoMethodError -> SomeException #

fromException :: SomeException -> Maybe NoMethodError #

displayException :: NoMethodError -> String #

Exception NonTermination 
Instance details

Defined in Control.Exception.Base

Methods

toException :: NonTermination -> SomeException #

fromException :: SomeException -> Maybe NonTermination #

displayException :: NonTermination -> String #

Exception PatternMatchFail 
Instance details

Defined in Control.Exception.Base

Methods

toException :: PatternMatchFail -> SomeException #

fromException :: SomeException -> Maybe PatternMatchFail #

displayException :: PatternMatchFail -> String #

Exception RecConError 
Instance details

Defined in Control.Exception.Base

Methods

toException :: RecConError -> SomeException #

fromException :: SomeException -> Maybe RecConError #

displayException :: RecConError -> String #

Exception RecSelError 
Instance details

Defined in Control.Exception.Base

Methods

toException :: RecSelError -> SomeException #

fromException :: SomeException -> Maybe RecSelError #

displayException :: RecSelError -> String #

Exception RecUpdError 
Instance details

Defined in Control.Exception.Base

Methods

toException :: RecUpdError -> SomeException #

fromException :: SomeException -> Maybe RecUpdError #

displayException :: RecUpdError -> String #

Exception TypeError 
Instance details

Defined in Control.Exception.Base

Methods

toException :: TypeError -> SomeException #

fromException :: SomeException -> Maybe TypeError #

displayException :: TypeError -> String #

Exception ErrorCall 
Instance details

Defined in GHC.Exception

Methods

toException :: ErrorCall -> SomeException #

fromException :: SomeException -> Maybe ErrorCall #

displayException :: ErrorCall -> String #

Exception ArithException 
Instance details

Defined in GHC.Exception.Type

Methods

toException :: ArithException -> SomeException #

fromException :: SomeException -> Maybe ArithException #

displayException :: ArithException -> String #

Exception SomeException 
Instance details

Defined in GHC.Exception.Type

Exception AllocationLimitExceeded 
Instance details

Defined in GHC.IO.Exception

Methods

toException :: AllocationLimitExceeded -> SomeException #

fromException :: SomeException -> Maybe AllocationLimitExceeded #

displayException :: AllocationLimitExceeded -> String #

Exception ArrayException 
Instance details

Defined in GHC.IO.Exception

Methods

toException :: ArrayException -> SomeException #

fromException :: SomeException -> Maybe ArrayException #

displayException :: ArrayException -> String #

Exception AssertionFailed 
Instance details

Defined in GHC.IO.Exception

Methods

toException :: AssertionFailed -> SomeException #

fromException :: SomeException -> Maybe AssertionFailed #

displayException :: AssertionFailed -> String #

Exception AsyncException 
Instance details

Defined in GHC.IO.Exception

Methods

toException :: AsyncException -> SomeException #

fromException :: SomeException -> Maybe AsyncException #

displayException :: AsyncException -> String #

Exception BlockedIndefinitelyOnMVar 
Instance details

Defined in GHC.IO.Exception

Methods

toException :: BlockedIndefinitelyOnMVar -> SomeException #

fromException :: SomeException -> Maybe BlockedIndefinitelyOnMVar #

displayException :: BlockedIndefinitelyOnMVar -> String #

Exception BlockedIndefinitelyOnSTM 
Instance details

Defined in GHC.IO.Exception

Methods

toException :: BlockedIndefinitelyOnSTM -> SomeException #

fromException :: SomeException -> Maybe BlockedIndefinitelyOnSTM #

displayException :: BlockedIndefinitelyOnSTM -> String #

Exception CompactionFailed 
Instance details

Defined in GHC.IO.Exception

Methods

toException :: CompactionFailed -> SomeException #

fromException :: SomeException -> Maybe CompactionFailed #

displayException :: CompactionFailed -> String #

Exception Deadlock 
Instance details

Defined in GHC.IO.Exception

Methods

toException :: Deadlock -> SomeException #

fromException :: SomeException -> Maybe Deadlock #

displayException :: Deadlock -> String #

Exception IOException 
Instance details

Defined in GHC.IO.Exception

Methods

toException :: IOException -> SomeException #

fromException :: SomeException -> Maybe IOException #

displayException :: IOException -> String #

Exception SomeAsyncException 
Instance details

Defined in GHC.IO.Exception

Methods

toException :: SomeAsyncException -> SomeException #

fromException :: SomeException -> Maybe SomeAsyncException #

displayException :: SomeAsyncException -> String #

Exception ExitCode 
Instance details

Defined in GHC.IO.Exception

Methods

toException :: ExitCode -> SomeException #

fromException :: SomeException -> Maybe ExitCode #

displayException :: ExitCode -> String #

Exception FixIOException 
Instance details

Defined in GHC.IO.Exception

Methods

toException :: FixIOException -> SomeException #

fromException :: SomeException -> Maybe FixIOException #

displayException :: FixIOException -> String #

data SomeException #

Instances

Instances details
Show SomeException 
Instance details

Defined in GHC.Exception.Type

Methods

showsPrec :: Int -> SomeException -> ShowS

show :: SomeException -> String

showList :: [SomeException] -> ShowS

Exception SomeException 
Instance details

Defined in GHC.Exception.Type

class Monad m => MonadException m where Source #

Minimal complete definition

throw, catch

Methods

throw :: Exception e => e -> m a Source #

Throw an exception.

catch Source #

Arguments

:: Exception e 
=> m a

The computation to run

-> (e -> m a)

Handler to invoke if an exception is raised

-> m a 

Catch an exception.

finally Source #

Arguments

:: m a

The computation to run

-> m b

Computation to run afterward (even if an exception was raised)

-> m a 

Run a computation and always perform a second, final computation even if an exception is raised. If a short-circuiting monad transformer such as ErrorT or MaybeT is used to transform a MonadException monad, then the implementation of finally for the transformed monad must guarantee that the final action is also always performed when any short-circuiting occurs.

Instances

Instances details
MonadException IO Source # 
Instance details

Defined in Control.Monad.Exception

Methods

throw :: Exception e => e -> IO a Source #

catch :: Exception e => IO a -> (e -> IO a) -> IO a Source #

finally :: IO a -> IO b -> IO a Source #

MonadException STM Source # 
Instance details

Defined in Control.Monad.Exception

Methods

throw :: Exception e => e -> STM a Source #

catch :: Exception e => STM a -> (e -> STM a) -> STM a Source #

finally :: STM a -> STM b -> STM a Source #

MonadException m => MonadException (ListT m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

throw :: Exception e => e -> ListT m a Source #

catch :: Exception e => ListT m a -> (e -> ListT m a) -> ListT m a Source #

finally :: ListT m a -> ListT m b -> ListT m a Source #

MonadException m => MonadException (MaybeT m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

throw :: Exception e => e -> MaybeT m a Source #

catch :: Exception e => MaybeT m a -> (e -> MaybeT m a) -> MaybeT m a Source #

finally :: MaybeT m a -> MaybeT m b -> MaybeT m a Source #

Monad m => MonadException (ExceptionT m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

throw :: Exception e => e -> ExceptionT m a Source #

catch :: Exception e => ExceptionT m a -> (e -> ExceptionT m a) -> ExceptionT m a Source #

finally :: ExceptionT m a -> ExceptionT m b -> ExceptionT m a Source #

(MonadException m, Error e) => MonadException (ErrorT e m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

throw :: Exception e0 => e0 -> ErrorT e m a Source #

catch :: Exception e0 => ErrorT e m a -> (e0 -> ErrorT e m a) -> ErrorT e m a Source #

finally :: ErrorT e m a -> ErrorT e m b -> ErrorT e m a Source #

MonadException m => MonadException (ExceptT e' m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

throw :: Exception e => e -> ExceptT e' m a Source #

catch :: Exception e => ExceptT e' m a -> (e -> ExceptT e' m a) -> ExceptT e' m a Source #

finally :: ExceptT e' m a -> ExceptT e' m b -> ExceptT e' m a Source #

MonadException m => MonadException (IdentityT m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

throw :: Exception e => e -> IdentityT m a Source #

catch :: Exception e => IdentityT m a -> (e -> IdentityT m a) -> IdentityT m a Source #

finally :: IdentityT m a -> IdentityT m b -> IdentityT m a Source #

MonadException m => MonadException (ReaderT r m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

throw :: Exception e => e -> ReaderT r m a Source #

catch :: Exception e => ReaderT r m a -> (e -> ReaderT r m a) -> ReaderT r m a Source #

finally :: ReaderT r m a -> ReaderT r m b -> ReaderT r m a Source #

MonadException m => MonadException (StateT s m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

throw :: Exception e => e -> StateT s m a Source #

catch :: Exception e => StateT s m a -> (e -> StateT s m a) -> StateT s m a Source #

finally :: StateT s m a -> StateT s m b -> StateT s m a Source #

MonadException m => MonadException (StateT s m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

throw :: Exception e => e -> StateT s m a Source #

catch :: Exception e => StateT s m a -> (e -> StateT s m a) -> StateT s m a Source #

finally :: StateT s m a -> StateT s m b -> StateT s m a Source #

(Monoid w, MonadException m) => MonadException (WriterT w m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

throw :: Exception e => e -> WriterT w m a Source #

catch :: Exception e => WriterT w m a -> (e -> WriterT w m a) -> WriterT w m a Source #

finally :: WriterT w m a -> WriterT w m b -> WriterT w m a Source #

(Monoid w, MonadException m) => MonadException (WriterT w m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

throw :: Exception e => e -> WriterT w m a Source #

catch :: Exception e => WriterT w m a -> (e -> WriterT w m a) -> WriterT w m a Source #

finally :: WriterT w m a -> WriterT w m b -> WriterT w m a Source #

(Monoid w, MonadException m) => MonadException (RWST r w s m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

throw :: Exception e => e -> RWST r w s m a Source #

catch :: Exception e => RWST r w s m a -> (e -> RWST r w s m a) -> RWST r w s m a Source #

finally :: RWST r w s m a -> RWST r w s m b -> RWST r w s m a Source #

(Monoid w, MonadException m) => MonadException (RWST r w s m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

throw :: Exception e => e -> RWST r w s m a Source #

catch :: Exception e => RWST r w s m a -> (e -> RWST r w s m a) -> RWST r w s m a Source #

finally :: RWST r w s m a -> RWST r w s m b -> RWST r w s m a Source #

onException Source #

Arguments

:: MonadException m 
=> m a

The computation to run

-> m b

Computation to run if an exception is raised

-> m a 

If an exception is raised by the computation, then perform a final action and re-raise the exception.

class (MonadIO m, MonadException m) => MonadAsyncException m where Source #

Methods

mask :: ((forall a. m a -> m a) -> m b) -> m b Source #

Executes a computation with asynchronous exceptions masked. The argument passed to mask is a function that takes as its argument another function, which can be used to restore the prevailing masking state within the context of the masked computation.

Instances

Instances details
MonadAsyncException IO Source # 
Instance details

Defined in Control.Monad.Exception

Methods

mask :: ((forall a. IO a -> IO a) -> IO b) -> IO b Source #

MonadAsyncException m => MonadAsyncException (ListT m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

mask :: ((forall a. ListT m a -> ListT m a) -> ListT m b) -> ListT m b Source #

MonadAsyncException m => MonadAsyncException (MaybeT m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

mask :: ((forall a. MaybeT m a -> MaybeT m a) -> MaybeT m b) -> MaybeT m b Source #

MonadAsyncException m => MonadAsyncException (ExceptionT m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

mask :: ((forall a. ExceptionT m a -> ExceptionT m a) -> ExceptionT m b) -> ExceptionT m b Source #

(MonadAsyncException m, Error e) => MonadAsyncException (ErrorT e m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

mask :: ((forall a. ErrorT e m a -> ErrorT e m a) -> ErrorT e m b) -> ErrorT e m b Source #

MonadAsyncException m => MonadAsyncException (ExceptT e' m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

mask :: ((forall a. ExceptT e' m a -> ExceptT e' m a) -> ExceptT e' m b) -> ExceptT e' m b Source #

MonadAsyncException m => MonadAsyncException (IdentityT m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

mask :: ((forall a. IdentityT m a -> IdentityT m a) -> IdentityT m b) -> IdentityT m b Source #

MonadAsyncException m => MonadAsyncException (ReaderT r m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

mask :: ((forall a. ReaderT r m a -> ReaderT r m a) -> ReaderT r m b) -> ReaderT r m b Source #

MonadAsyncException m => MonadAsyncException (StateT s m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

mask :: ((forall a. StateT s m a -> StateT s m a) -> StateT s m b) -> StateT s m b Source #

MonadAsyncException m => MonadAsyncException (StateT s m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

mask :: ((forall a. StateT s m a -> StateT s m a) -> StateT s m b) -> StateT s m b Source #

(Monoid w, MonadAsyncException m) => MonadAsyncException (WriterT w m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

mask :: ((forall a. WriterT w m a -> WriterT w m a) -> WriterT w m b) -> WriterT w m b Source #

(Monoid w, MonadAsyncException m) => MonadAsyncException (WriterT w m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

mask :: ((forall a. WriterT w m a -> WriterT w m a) -> WriterT w m b) -> WriterT w m b Source #

(Monoid w, MonadAsyncException m) => MonadAsyncException (RWST r w s m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

mask :: ((forall a. RWST r w s m a -> RWST r w s m a) -> RWST r w s m b) -> RWST r w s m b Source #

(Monoid w, MonadAsyncException m) => MonadAsyncException (RWST r w s m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

mask :: ((forall a. RWST r w s m a -> RWST r w s m a) -> RWST r w s m b) -> RWST r w s m b Source #

bracket Source #

Arguments

:: MonadAsyncException m 
=> m a

computation to run first ("acquire resource")

-> (a -> m b)

computation to run last ("release resource")

-> (a -> m c)

computation to run in-between

-> m c 

When you want to acquire a resource, do some work with it, and then release the resource, it is a good idea to use bracket, because bracket will install the necessary exception handler to release the resource in the event that an exception is raised during the computation. If an exception is raised, then bracket will re-raise the exception (after performing the release).

bracket_ :: MonadAsyncException m => m a -> m b -> m c -> m c Source #

A variant of bracket where the return value from the first computation is not required.

newtype ExceptionT m a Source #

Constructors

ExceptionT 

Fields

Instances

Instances details
MonadTrans ExceptionT Source # 
Instance details

Defined in Control.Monad.Exception

Methods

lift :: Monad m => m a -> ExceptionT m a

Monad m => Monad (ExceptionT m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

(>>=) :: ExceptionT m a -> (a -> ExceptionT m b) -> ExceptionT m b

(>>) :: ExceptionT m a -> ExceptionT m b -> ExceptionT m b

return :: a -> ExceptionT m a

Functor m => Functor (ExceptionT m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

fmap :: (a -> b) -> ExceptionT m a -> ExceptionT m b

(<$) :: a -> ExceptionT m b -> ExceptionT m a

MonadFix m => MonadFix (ExceptionT m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

mfix :: (a -> ExceptionT m a) -> ExceptionT m a

Monad m => MonadFail (ExceptionT m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

fail :: String -> ExceptionT m a

(Functor m, Monad m) => Applicative (ExceptionT m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

pure :: a -> ExceptionT m a

(<*>) :: ExceptionT m (a -> b) -> ExceptionT m a -> ExceptionT m b

liftA2 :: (a -> b -> c) -> ExceptionT m a -> ExceptionT m b -> ExceptionT m c

(*>) :: ExceptionT m a -> ExceptionT m b -> ExceptionT m b

(<*) :: ExceptionT m a -> ExceptionT m b -> ExceptionT m a

(Functor m, Monad m) => Alternative (ExceptionT m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

empty :: ExceptionT m a

(<|>) :: ExceptionT m a -> ExceptionT m a -> ExceptionT m a

some :: ExceptionT m a -> ExceptionT m [a]

many :: ExceptionT m a -> ExceptionT m [a]

Monad m => MonadPlus (ExceptionT m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

mzero :: ExceptionT m a

mplus :: ExceptionT m a -> ExceptionT m a -> ExceptionT m a

MonadIO m => MonadIO (ExceptionT m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

liftIO :: IO a -> ExceptionT m a

MonadAsyncException m => MonadAsyncException (ExceptionT m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

mask :: ((forall a. ExceptionT m a -> ExceptionT m a) -> ExceptionT m b) -> ExceptionT m b Source #

Monad m => MonadException (ExceptionT m) Source # 
Instance details

Defined in Control.Monad.Exception

Methods

throw :: Exception e => e -> ExceptionT m a Source #

catch :: Exception e => ExceptionT m a -> (e -> ExceptionT m a) -> ExceptionT m a Source #

finally :: ExceptionT m a -> ExceptionT m b -> ExceptionT m a Source #

mapExceptionT :: (m (Either SomeException a) -> n (Either SomeException b)) -> ExceptionT m a -> ExceptionT n b Source #

liftException :: MonadException m => Either SomeException a -> m a Source #

Lift the result of running a computation in a monad transformed by ExceptionT into another monad that supports exceptions.