
Hello *, I am just curious: Why does Haskell not provide exceptions a la SML? Why does only the IO monad allow for exceptions? Michael

Hello, I may be wrong but I think that one reason is that this piece of code : try (raise A) + (raise B) with A -> 1 | B -> 2 (in CAML lyke style) booth reduce to 1 and to 2, depending of the order of evaluation of the arguments of a function call. That is something quite dangerous and not wanted in Haskell (where moreover sue to lazyness, the order of evaluation is difficult to predict.) Greetings, Nicolas Oury On Thu, 22 Nov 2001, Michael Marte wrote:
Hello *,
I am just curious: Why does Haskell not provide exceptions a la SML? Why does only the IO monad allow for exceptions?
Michael
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Hello *,
I am just curious: Why does Haskell not provide exceptions a la SML? Why does only the IO monad allow for exceptions?
GHC certainly implements exceptions, along the lines described in A semantics for imprecise exceptions, Simon Peyton Jones, Alastair Reid, Tony Hoare, Simon Marlow, Fergus Henderson. Proc Programming Languages Design and Implementation (PLDI'99), Atlanta. http://research.microsoft.com/Users/simonpj/Papers/imprecise-exn.htm As described there, * you can *raise* an exception anywhere, * but you can only *catch* an exception in the IO monad. This is essentially because exceptional behaviour is `impure', and Haskell's way of dealing with impure behaviour (like files, user input, global state, and so on) is via the IO monad. HTH. There's more in the paper. --KW 8-)

On 22-Nov-2001, Keith Wansbrough
I am just curious: Why does Haskell not provide exceptions a la SML? Why does only the IO monad allow for exceptions?
GHC certainly implements exceptions, along the lines described in
A semantics for imprecise exceptions, Simon Peyton Jones, Alastair Reid, Tony Hoare, Simon Marlow, Fergus Henderson. Proc Programming Languages Design and Implementation (PLDI'99), Atlanta.
... and the main reason why Haskell 98 didn't incorporate this is because,
well, 98 was before 99 ;-).
In other words, it wasn't well understood at the time the Haskell
report was being written. But I think exception support along the
lines suggested in that paper and implemented in GHC is very likely to
be included in the next revision of Haskell.
That's my opinion, anyway, though of course I am somewhat
biased on this issue! ;-)
--
Fergus Henderson
participants (4)
-
Fergus Henderson
-
Keith Wansbrough
-
Michael Marte
-
Nicolas Oury