This module is designed to be used in production code when no runtime exceptions are expected. This module will catch any unexpected runtime exception and send a notification email
This package provides exception monad transformer instances for the classes defined by monads-fd.
This package provides exception monad transformer instances for the classes defined by monads-tf.
This package provides exception monad transformer instances for the classes defined by mtl2.
This package provides type classes, a monad and a monad transformer that support unchecked extensible exceptions as well as asynchronous exceptions. It is compatible with the transformers package.
Extensible optionally-pure exceptions
This package provides explicitly typed, checked exceptions as a library.
Computations throwing different types of exception can be combined seamlessly.
> data Expr = Add Expr Expr | Div Expr Expr | Val Double
> eval (Val x) = return x
> eval (Add a1 a2) = do
> v1 <- eval a1
> v2 <- eval a2
> let sum = v1 + v2
> if sum < v1 || sum < v2 then throw SumOverflow else return sum
> eval (Div a1 a2) = do
> v1 <- eval a1
> v2 <- eval a2
> if v2 == 0 then throw DivideByZero else return (v1 / v2)
> data DivideByZero = DivideByZero deriving (Show, Typeable)
> data SumOverflow = SumOverflow deriving (Show, Typeable)
> instance Exception DivideByZero
> instance Exception SumOverflow
GHCi infers the following types
> eval :: (Throws DivideByZero l, Throws SumOverflow l) =>
> Expr -> EM l Double
> eval `catch` \ (e::DivideByZero) -> return (-1) :: Throws
> SumOverflow l => Expr -> EM l Double
> runEM(eval `catch` \ (e::SomeException) -> return (-1))
> :: Expr -> Double
In addition to explicitly typed exceptions his package provides:
* Support for explicitly documented, unchecked exceptions (via Control.Monad.Exception.tryEMT).
* Support for selective unchecked exceptions (via Control.Monad.Exception.UncaughtException).
* Support for exception call traces via Control.Monad.Loc.MonadLoc. Example:
> f () = do throw MyException
> g a = do f a
> main = runEMT $ do g () `catchWithSrcLoc`
> \loc (e::MyException) -> lift(putStrLn$
> showExceptionWithTrace loc e)
> -- Running main produces the output:
> *Main> main
> in f, Main(example.hs): (1,6)
> g, Main(example.hs): (2,6)
> main, Main(example.hs): (5,9)
> main, Main(example.hs): (4,16)
* 0.9.0 - Moved to transformers (finally leaving the whole mtl-transformers cisma behind)
* 0.10.0 - removed the dependency on safe-failure
* 0.10.1 - compatibility with failure 0.2 (thanks to Bas van Dijk)
* 0.10.2 - use the identity type from mtl (thanks to Bas), require minimum cabal-install version (thanks to Bernhard Urban)
* 0.10.3 - Moved the MonadIO instance to the main package
* 0.10.3.1 - Compatibility with base 4.6
Monads-fd instances for the EMT exceptions monad transformer
Monads-tf instances for the EMT exceptions monad transformer
MTL classes instances for the EMT exceptions monad transformer
Synchronous and Asynchronous exceptions which are explicit in the type signature. The first ones are very similar to Either and Control.Monad.Error.ErrorT. The second ones are used for System.IO.readFile and System.IO.hGetContents. This package is a proposal for improved exception handling in Haskell. It strictly separates between handling of exceptional situations (file not found, invalid user input, see http://www.haskell.org/haskellwiki/Exception) and (programming) errors (division by zero, index out of range, see http://www.haskell.org/haskellwiki/Error). Handling of the first one is called "exception handling", whereas handling of errors is better known as "debugging".
For applications see the packages midi, spreadsheet, http-monad.
Although I'm not happy with the identifier style of the Monad Transformer Library (partially intended for unqualified use) I have tried to adopt it for this library, in order to let Haskell programmers get accustomed easily to it.
To do: Because many people requested it, we will provide a bracket function that frees a resource both when an exception and an error occurs, that is, it combines exception handling and debugging. However note that freeing resources in case of an error is dangerous and may cause further damage.
This package provides extensible exceptions for both new and old versions of GHC (i.e., < 6.10).
This module was generated by interleavableGen.
Extensible exceptions are a good solution to the exception problem in Haskell. However, there is one problem: they are not extensible enough! The problem is that the functions defined in Control.Exception for dealing with exceptions can only be used with the IO monad. A lot of Haskell code uses a stack of monads, at the bottom of which is IO, but the IO monad is not used directly.
There have been many attempts to solve this problem, but the stumbling block has been the presence of short-circuiting monad transformers: sometimes, these prevented the cleanup actions from being run, making it effectively impossible to catch exceptions in such monads. The monad-control package has been developed as a solution to this problem: it defines a way to turn a monad transformer stack "inside-out", which ensures that cleanup actions are run even when the original action short-circuits. The lifted-base package, built on top of monad-control, exports the Control.Exception.Lifted module, which contains versions of the Control.Exception functions that work on any monad stack with IO at its base.
This has pretty much solved the above problems. However, one thing that the solutions that came before monad-control did was provide a type class encapsulating exception functionality that could be implemented by pure monads, allowing you to use the same interface to throw and catch exceptions in both pure and IO-based code. This also makes it possible to express which can throw an exception, but which don't necessarily do any IO and which are polymorphic in their exception throwing (i.e., you could run the function in IO and it would use throwIO, or you could run it as an Either and it would use Left).
That's what this package does. It provides a MonadException type class (in the Control.Monad.Exception.Class module), which has instances for IO and IO-like monads (for which monad-control is used to provide the correct instances as described above), as well as for some pure monads. Several overlapping instances (in the spirit of mtl-evil-instances) are provided, so it is not necessary to provide a pass-through instance for MonadException for every monad transformer you write.
This package also defines an ExceptionT monad transformer (in Control.Monad.Trans.Exception) that can be used to add MonadException functionality to otherwise pure monad stacks. mtl-evil-instances is used to automatically provide pass-through instances for the mtl type classes for this transformer.
Finally, this package includes the module Control.Exception.Monadic, which is a full replacement for Control.Exception, whose functions work on any instance of MonadException and not just IO. The functions for dealing with asynchronous exceptions require IO however, so these are only polymorphic for any IO-like monadic (as determined by monad-control).
This package defines a monad transformer for resumable exceptions; like ErrorT except the exceptions include a resumption. It interoperates with the mtl monads, but beware!, many of those instances are unvalidated.
When you've caught all the exceptions that can be handled safely, this is what you're left with.