Exceptions

John Meacham john at repetae.net
Sat Apr 8 05:18:27 EDT 2006


On Sat, Apr 08, 2006 at 12:11:51AM -0400, David Menendez wrote:
> > newtype ArithException a = ArithException a
> > 
> > data DivideByZero
> > 
> > throw (ArithException DivideByZero)
> > 
> > your code:
> > 
> > data MultiplyByZero
> > throw (ArithException MultiplyByZero)
> 
> How would you use this to write a handler that captures any
> ArithException?

You would use the Typeable1 class in Data.Typeable. not perfect, but
exception hierarchies shouldn't be too deep so it is not so bad.

        John

-- 
John Meacham - ⑆repetae.net⑆john⑈


More information about the Haskell-prime mailing list