Excerpts from Immanuel Litzroth's message of Wed Jan 07 16:53:30 -0600 2009: > I'm trying to use the new (for me at least) extensible exceptions and > I am little amazed that I cannot get catch, try or mapException to work > without telling them which exceptions I want to catch. > What is the rationale behind this?
The rational is that it's normally not a good idea to simply gobble all exceptions; although the library makes it possible to do this anyway. You can either use the ScopedTypeVariables extension and do: ... `catch` \(e::SomeException) -> ... Or without an extension you can do: ... `catch` handler where handler :: SomeException -> IO a handler e = ... (It's really a matter of taste if you want to use a non-haskell98 extension, although considering that the new extensible exceptions library uses deriving data/typeable and existentials anyway, I think ScopedTypeVariables are the way to go.) > How does bracket manage to catch all exceptions? > What should onException do? onException takes an IO action and what to do if it fails - if the IO action fails, it is caught and your 'failure action' is run, followed by onException re-throwing the error. > Is there some example code that uses these exceptions, or better > documentation? The GHC docs don't have source-code links (don't know why,) but luckily in order to aid in using the new extensions system with older GHCs there has been a hackage package uploaded that provides the identical functionality: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/extensible-exceptions The source is here: http://hackage.haskell.org/packages/archive/extensible-exceptions/0.1.1.0/doc/html/src/Control-Exception-Extensible.html As for documentation e.g. haddock stuff, this is currently a bug as there is none: http://hackage.haskell.org/trac/ghc/ticket/2655 I recommend this paper for info, it's very easy to follow: http://www.haskell.org/~simonmar/papers/ext-exceptions.pdf Austin _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe