Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell98 |
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
- class MonadIO m => MonadCatchIO m where
- class (Typeable e, Show e) => Exception e where
- toException :: e -> SomeException
- fromException :: SomeException -> Maybe e
- displayException :: e -> String
- 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 Source #
Instances
MonadCatchIO IO Source # | |
MonadCatchIO m => MonadCatchIO (ListT m) Source # | |
MonadCatchIO m => MonadCatchIO (MaybeT m) 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
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 (IdentityT m) Source # | |
MonadCatchIO m => MonadCatchIO (ReaderT r m) Source # | |
MonadCatchIO m => MonadCatchIO (StateT s m) Source # | |
MonadCatchIO m => MonadCatchIO (StateT s m) Source # | |
(Monoid w, MonadCatchIO m) => MonadCatchIO (WriterT w m) Source # | |
(Monoid w, MonadCatchIO m) => MonadCatchIO (WriterT w m) Source # | |
MonadCatchIO m => MonadCatchIO (ContT r m) Source # | 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) Source # | |
(Monoid w, MonadCatchIO m) => MonadCatchIO (RWST r w s m) 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
Exception ArithException | |
Defined in GHC.Exception.Type Methods toException :: ArithException -> SomeException # fromException :: SomeException -> Maybe ArithException # displayException :: ArithException -> String # | |
Exception SomeException | |
Defined in GHC.Exception.Type Methods toException :: SomeException -> SomeException # fromException :: SomeException -> Maybe SomeException # displayException :: SomeException -> String # | |
Exception AllocationLimitExceeded | |
Defined in GHC.IO.Exception Methods toException :: AllocationLimitExceeded -> SomeException # fromException :: SomeException -> Maybe AllocationLimitExceeded # displayException :: AllocationLimitExceeded -> String # | |
Exception ArrayException | |
Defined in GHC.IO.Exception Methods toException :: ArrayException -> SomeException # fromException :: SomeException -> Maybe ArrayException # displayException :: ArrayException -> String # | |
Exception AssertionFailed | |
Defined in GHC.IO.Exception Methods toException :: AssertionFailed -> SomeException # fromException :: SomeException -> Maybe AssertionFailed # displayException :: AssertionFailed -> String # | |
Exception AsyncException | |
Defined in GHC.IO.Exception Methods toException :: AsyncException -> SomeException # fromException :: SomeException -> Maybe AsyncException # displayException :: AsyncException -> String # | |
Exception BlockedIndefinitelyOnMVar | |
Defined in GHC.IO.Exception Methods toException :: BlockedIndefinitelyOnMVar -> SomeException # fromException :: SomeException -> Maybe BlockedIndefinitelyOnMVar # displayException :: BlockedIndefinitelyOnMVar -> String # | |
Exception BlockedIndefinitelyOnSTM | |
Defined in GHC.IO.Exception Methods toException :: BlockedIndefinitelyOnSTM -> SomeException # fromException :: SomeException -> Maybe BlockedIndefinitelyOnSTM # displayException :: BlockedIndefinitelyOnSTM -> String # | |
Exception CompactionFailed | |
Defined in GHC.IO.Exception Methods toException :: CompactionFailed -> SomeException # fromException :: SomeException -> Maybe CompactionFailed # displayException :: CompactionFailed -> String # | |
Exception Deadlock | |
Defined in GHC.IO.Exception Methods toException :: Deadlock -> SomeException # fromException :: SomeException -> Maybe Deadlock # displayException :: Deadlock -> String # | |
Exception ExitCode | |
Defined in GHC.IO.Exception Methods toException :: ExitCode -> SomeException # fromException :: SomeException -> Maybe ExitCode # displayException :: ExitCode -> String # | |
Exception FixIOException | |
Defined in GHC.IO.Exception Methods toException :: FixIOException -> SomeException # fromException :: SomeException -> Maybe FixIOException # displayException :: FixIOException -> String # | |
Exception IOException | |
Defined in GHC.IO.Exception Methods toException :: IOException -> SomeException # fromException :: SomeException -> Maybe IOException # displayException :: IOException -> String # | |
Exception SomeAsyncException | |
Defined in GHC.IO.Exception Methods toException :: SomeAsyncException -> SomeException # fromException :: SomeException -> Maybe SomeAsyncException # displayException :: SomeAsyncException -> String # |
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
Generalized version of Handler
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
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 Source #
Generalized version of onException