MonadCatchIO-transformers-0.3.1.3: Monad-transformer compatible version of the Control.Exception module
Safe HaskellSafe-Inferred
LanguageHaskell98

Control.Monad.CatchIO

Contents

Description

Please consider using the package exceptions instead, if possible.

The functions block and unblock, which are part of the MonadCatchIO class, have known problems. The IO instances of these functions, which are provided by the base library, have been deprecated for some time, and have been removed in base-4.7.

Synopsis

Documentation

class MonadIO m => MonadCatchIO m where Source #

Methods

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

Generalized version of catch

block :: m a -> m a Source #

unblock :: m a -> m a Source #

Instances

Instances details
MonadCatchIO IO Source # 
Instance details

Defined in Control.Monad.CatchIO

Methods

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

block :: IO a -> IO a Source #

unblock :: IO a -> IO a Source #

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

Defined in Control.Monad.CatchIO

Methods

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

block :: ListT m a -> ListT m a Source #

unblock :: ListT m a -> ListT m a Source #

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

Defined in Control.Monad.CatchIO

Methods

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

block :: MaybeT m a -> MaybeT m a Source #

unblock :: MaybeT m a -> MaybeT m a Source #

(MonadCatchIO m, Error e) => MonadCatchIO (ErrorT e m) Source #

Warning: this instance is somewhat contentious.

Note that in monads that fall under this instance (the most basic example is ErrorT e IO), there are errors of two sorts:

  1. exceptions, (i.e., exceptional values in the underlying IO monad);
  2. error values of type e, introduced by the ErrorT e part of the monad.

The instance takes no special action to deal with errors of type 2. In particular, bracket will not perform its second argument, if its third argument decides to "exit early" by throwing an error of type 2.

This may or may not be what you want.

See the mailing list thread starting with http://www.mail-archive.com/haskell-cafe@haskell.org/msg82859.html for some details.

Instance details

Defined in Control.Monad.CatchIO

Methods

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

block :: ErrorT e m a -> ErrorT e m a Source #

unblock :: ErrorT e m a -> ErrorT e m a Source #

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

Defined in Control.Monad.CatchIO

Methods

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

block :: IdentityT m a -> IdentityT m a Source #

unblock :: IdentityT m a -> IdentityT m a Source #

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

Defined in Control.Monad.CatchIO

Methods

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

block :: ReaderT r m a -> ReaderT r m a Source #

unblock :: ReaderT r m a -> ReaderT r m a Source #

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

Defined in Control.Monad.CatchIO

Methods

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

block :: StateT s m a -> StateT s m a Source #

unblock :: StateT s m a -> StateT s m a Source #

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

Defined in Control.Monad.CatchIO

Methods

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

block :: StateT s m a -> StateT s m a Source #

unblock :: StateT s m a -> StateT s m a Source #

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

Defined in Control.Monad.CatchIO

Methods

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

block :: WriterT w m a -> WriterT w m a Source #

unblock :: WriterT w m a -> WriterT w m a Source #

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

Defined in Control.Monad.CatchIO

Methods

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

block :: WriterT w m a -> WriterT w m a Source #

unblock :: WriterT w m a -> WriterT w m a Source #

MonadCatchIO m => MonadCatchIO (ContT r m) Source #

Warning: this instance is somewhat contentious.

In the same way that the ErrorT e instance may fail to perform the final action, due to the "early exit" behaviour of the monad, this instance may perform the final action any number of times, due to the nonlinear nature of the continuation monad.

See the mailing list message http://web.archiveorange.com/archive/v/nDNOvaYx1poDHZNlmlgh for an example of what can go wrong (freeing memory twice).

Instance details

Defined in Control.Monad.CatchIO

Methods

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

block :: ContT r m a -> ContT r m a Source #

unblock :: ContT r m a -> ContT r m a Source #

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

Defined in Control.Monad.CatchIO

Methods

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

block :: RWST r w s m a -> RWST r w s m a Source #

unblock :: RWST r w s m a -> RWST r w s m a Source #

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

Defined in Control.Monad.CatchIO

Methods

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

block :: RWST r w s m a -> RWST r w s m a Source #

unblock :: RWST r w s m a -> RWST r w s m a Source #

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

Methods

toException :: SomeException -> SomeException #

fromException :: SomeException -> Maybe SomeException #

displayException :: SomeException -> String #

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

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 #

throw :: (MonadIO m, Exception e) => e -> m a Source #

Generalized version of throwIO

try :: (MonadCatchIO m, Functor m, Exception e) => m a -> m (Either e a) Source #

Generalized version of try

tryJust :: (MonadCatchIO m, Functor m, Exception e) => (e -> Maybe b) -> m a -> m (Either b a) Source #

Generalized version of tryJust

data Handler m a Source #

Generalized version of Handler

Constructors

forall e.Exception e => Handler (e -> m a) 

catches :: MonadCatchIO m => m a -> [Handler m a] -> m a Source #

Generalized version of catches

Utilities

bracket :: MonadCatchIO m => m a -> (a -> m b) -> (a -> m c) -> m c Source #

Generalized version of bracket

bracket_ Source #

Arguments

:: MonadCatchIO m 
=> m a

computation to run first ("acquire resource")

-> m b

computation to run last ("release resource")

-> m c

computation to run in-between

-> m c 

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

bracketOnError Source #

Arguments

:: MonadCatchIO 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 

Like bracket, but only performs the final action if there was an exception raised by the in-between computation.

finally Source #

Arguments

:: MonadCatchIO m 
=> m a

computation to run first

-> m b

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

-> m a 

A specialised variant of bracket with just a computation to run afterward.

onException :: MonadCatchIO m => m a -> m b -> m a Source #

Generalized version of onException