[Haskell] Better Exception Handling

Jules Bean jules at jellybean.co.uk
Wed Nov 24 13:12:27 EST 2004


On 24 Nov 2004, at 16:21, Scott Turner wrote:

> On 2004 November 23 Tuesday 10:51, John Goerzen wrote:
> The way to deal with those kinds of details is to use Either in a  
> monad.  I'm
> skeptical of the need for dynamic scope in conventional exception  
> handling,
> so I took a shot at this problem, with satisfying results.  (I'm not  
> keen on
> dynamic typing for that matter, but don't know of a nice way to avoid  
> it.)
> Excerpts are below.  The full sample code is at
> http://pkturner.org/exception.tar
>

Ok, I glanced through your code, and you seem to be reimplementing many  
of the ideas in the MonadError class, which also makes Either into a  
Monad.

http://www.haskell.org/ghc/docs/latest/html/libraries/base/ 
Control.Monad.Error.html

Would you care to clarify the important differences? It looks like your  
support for hierarchies of exceptions is an enhancement? The external  
interface looks nice, the internal implementation with fromDynamic  
doesn't seem pretty though :-(

Jules



More information about the Haskell mailing list