Application letters at the Haskell workshop: suggestion
Fri, 14 Sep 2001 08:10:40 -0700
"Manuel M. T. Chakravarty" wrote:
> Maybe it should be clarified that there are exceptions in
> H98, but *only* in the IO monad. What the extension is
> about are exceptions in pure functions.
Further clarification: the extension allows you to _raise_ exceptions in pure
functions, but you may only catch them in the IO monad.
This asymmetry is very important for Haskell, since otherwise evaluation order
would be observable. This would break many important equalities and render
almost any optimizations unsafe (i.e., GHC would be crippled). ML allows one
to catch exceptions in pure functions with impunity, and can do so because
evaluation order is fixed. The story is similar for imperative languages.
A further extension to this exceptions mechanism allows one to catch
asynchronous exceptions (e.g., interrupts or UNIX signals) in the IO monad,
and to signal (or "raise an asynchronous exception in") other threads. There
are also scope-based operators "block" and "unblock" which, given a
computation, perform it with asynchronous exceptions blocked/unblocked
respectively. They may be nested arbitrarily. I believe GHC is the only
system with this extension implemented thus far, but there are rumours of Hugs
not being far behind (I'm looking at you, Alastair David :-)
The exceptions mechanisms would certainly benefit from an addendum.
Andy Moran Ph. (503) 526 3472
Galois Connections Inc. Fax. (503) 350 0833
3875 SW Hall Blvd. http://www.galconn.com
Beaverton, OR 97005 email@example.com