simonmar at microsoft.com
Mon Apr 10 06:25:09 EDT 2006
On 08 April 2006 10:18, John Meacham wrote:
> 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
> 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.
I mentioned this solution to John G. off-list; the problem is that you
end up needing to parameterise all the classes of exceptions (we'd have
IOException a, ArrayException a, AsyncException a, etc.).
Given that we've already made the Exception type sideways extensible
with a simple application of type classes and dynamic types, we can take
the technique a bit further to create an extensible hierarchy of
exceptions, which is what John wants.
To create a new subclass of exceptions:
More information about the Haskell-prime