Safe Haskell | None |
---|
Control.Monad.CatchIO
Contents
Description
Warning: this module is deprecated.
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.
- class MonadIO m => MonadCatchIO m where
- class (Typeable e, Show e) => Exception e where
- toException :: e -> SomeException
- fromException :: SomeException -> Maybe e
- throw :: (MonadIO m, Exception e) => e -> m a
- try :: (MonadCatchIO m, Functor m, Exception e) => m a -> m (Either e a)
- tryJust :: (MonadCatchIO m, Functor m, Exception e) => (e -> Maybe b) -> m a -> m (Either b a)
- data Handler m a = forall e . Exception e => Handler (e -> m a)
- catches :: MonadCatchIO m => m a -> [Handler m a] -> m a
- bracket :: MonadCatchIO m => m a -> (a -> m b) -> (a -> m c) -> m c
- bracket_ :: MonadCatchIO m => m a -> m b -> m c -> m c
- bracketOnError :: MonadCatchIO m => m a -> (a -> m b) -> (a -> m c) -> m c
- finally :: MonadCatchIO m => m a -> m b -> m a
- onException :: MonadCatchIO m => m a -> m b -> m a
Documentation
class MonadIO m => MonadCatchIO m where
Methods
catch :: Exception e => m a -> (e -> m a) -> m a
Generalized version of catch
block :: m a -> m a
unblock :: m a -> m a
Instances
MonadCatchIO IO | |
MonadCatchIO m => MonadCatchIO (MaybeT m) | |
MonadCatchIO m => MonadCatchIO (ListT m) | |
MonadCatchIO m => MonadCatchIO (IdentityT m) | |
(Monoid w, MonadCatchIO m) => MonadCatchIO (WriterT w m) | |
(Monoid w, MonadCatchIO m) => MonadCatchIO (WriterT w m) | |
MonadCatchIO m => MonadCatchIO (StateT s m) | |
MonadCatchIO m => MonadCatchIO (StateT s m) | |
MonadCatchIO m => MonadCatchIO (ReaderT r m) | |
(MonadCatchIO m, Error e) => MonadCatchIO (ErrorT e m) | Warning: this instance is somewhat contentious. Note that in monads that fall under this instance (the most basic example
is
The instance takes no special action to deal with errors of type 2.
In particular, 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. |
MonadCatchIO m => MonadCatchIO (ContT r m) | Warning: this instance is somewhat contentious. In the same way that the See the mailing list message http://web.archiveorange.com/archive/v/nDNOvaYx1poDHZNlmlgh for an example of what can go wrong (freeing memory twice). |
(Monoid w, MonadCatchIO m) => MonadCatchIO (RWST r w s m) | |
(Monoid w, MonadCatchIO m) => MonadCatchIO (RWST r w s m) |
class (Typeable e, Show e) => Exception e where
Instances
Exception IOException | |
Exception Deadlock | |
Exception BlockedIndefinitelyOnSTM | |
Exception BlockedIndefinitelyOnMVar | |
Exception AsyncException | |
Exception AssertionFailed | |
Exception ArrayException | |
Exception SomeException | |
Exception ErrorCall | |
Exception ArithException | |
Exception RecUpdError | |
Exception RecSelError | |
Exception RecConError | |
Exception PatternMatchFail | |
Exception NonTermination | |
Exception NoMethodError | |
Exception NestedAtomically | |
Exception ExitCode |
try :: (MonadCatchIO m, Functor m, Exception e) => m a -> m (Either e a)
Generalized version of try
tryJust :: (MonadCatchIO m, Functor m, Exception e) => (e -> Maybe b) -> m a -> m (Either b a)
Generalized version of tryJust
data Handler m a
Generalized version of Handler
catches :: MonadCatchIO m => m a -> [Handler m a] -> m a
Generalized version of catches
Utilities
bracket :: MonadCatchIO m => m a -> (a -> m b) -> (a -> m c) -> m c
Generalized version of bracket
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.
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.
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
Generalized version of onException