Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the DynamicException equivalent in the post-ghc-7.6.1 world?

Tags:

haskell

ghc

DynamicException and throwDyn and throwDynTo used to be in the Control.OldException module. Now that OldException is gone for good, packages that relied on it are broken.

Is there an equivalent of DynamicException in the ExtensibleException package or elsewhere? I'd like to get away with minimal changes.

Context: I'm trying to build lambdabot with GHC 7.6.1. The broken file is Signal.hs in lambdabot-utils.

Update Is there some kind of guide for porting old exceptions code to new extensible exceptions? lambdabot uses OldException in several places, a quick fix doesn't seem possible.

like image 442
n. 1.8e9-where's-my-share m. Avatar asked Sep 24 '12 08:09

n. 1.8e9-where's-my-share m.


1 Answers

The equivalents of these functions in the new Control.Exception are simply throw, throwTo and catch, as Control.Exception supports dynamic exceptions by default.

The main difference between the old interface and the new one is that these functions have an Exception constraint rather than Typeable. However, in most cases the default implementation is good enough, so you simply need to declare Exception instances for the types you want to use, e.g.

instance Exception Foo
like image 88
hammar Avatar answered Nov 03 '22 16:11

hammar