At 2:40 pm 10/6/98, Simon L Peyton Jones wrote:
>Here's a reasonable design for exceptions in Haskell:
>
>* A value of Haskell type T can be
>        EITHER one of the values we know and love
>               (bottom, or constructor, or function,
>                depending on T),
>
>        OR it can be a set of exceptional values.

>I'd be interested to know what people think of this.

The error values and raising are similar to my PhD thesis (the type
domains weren't a big problem -- it's technically straightforward [though
perhaps philosophically debatable] to add additional values to a domain if
you wish,
and preserve these through other domains)!  [For the record, this was in an
early SML,
and the current SML design is broadly similar to this, but with extendible
exceptions (and a fixed evaluation order) as Ralf Hinze notes].
The non-deterministic handling is interesting and eliminating
the error checks is a good thing, of course.

One issue in my system was what to do for partial applications (do they return
an exception instantly or only when fully applied -- I suppose in this setting
you return the union of the possibilities and do whatever's convenient
in the implementation).  You also have to worry about what to when an exception
raises an exception when you try to look at it in the handler (probably raised
to a higher-level rather than handled locally).  A parallel setting (one of
my PhD motivations) would need a little care to avoid invoking the same handler
multiple times if several threads raised exceptions.

One thing you haven't noted:  doesn't this also work for user interrupts
too (Control-C)
-- presumably there's no reason why it shouldn't (it did in my setting).

Incidentally, why have you put the handler first?  It stops you writing

        e `handle` h

as with catch, and I'd expect would make it a bit harder to convert code?

Regards,
Kevin

----------
Division of Computer Science,               Tel: +44-1334 463241 (Direct)
School of Mathematical                      Fax: +44-1334 463278
 and Computational Sciences,                URL:
http://www.dcs.st-and.ac.uk/~kh/kh.html
University of St. Andrews, Fife, KY16 9SS.



Reply via email to