[Haskell] Better Exception Handling

Jules Bean jules at jellybean.co.uk
Wed Nov 24 14:44:37 EST 2004


On 24 Nov 2004, at 19:16, Scott Turner wrote:
>
> Each error type is an instance of Hierarchical, so that its errors may 
> be
> considered part of a larger category of errors.  In the instance 
> definition,
> 'parent' specifies how the error appears if it is caught by a handler
> expecting then next more general error type.
>

Dynamic seems to be a sledgehammer for this particular nut.

Can we not have a type class for 'subtyping' (like your hierarchical). 
Can multi-parameter typeclasses do this? We want:

class SubType a b where
	inject :: a -> b

and

instance SubType a b,SubType b c => SubType a c where
	inject :: a -> c
	inject some_a = inject ((inject some_a) :: b)

and then the definition of `except` requires that the SubType relates 
the type of the handler and the type of the actual error?

Jules



More information about the Haskell mailing list