Fergus Henderson wrote:
[snip]
> SML's exception mechanism essentially forces sequential execution,
> and (I think) causes problems for equational reasoning.
> Haskell's exception mechanism preserves referential transparency
> and gives the compiler more freedom to reorder and/or parallelize code.
OK, I've looked at the paper now. I think Fergus misunderstood me (so my
fault). The bit of SML's exception mechanism I think applicable to Haskell
is the extensible datatype bit. I certainly _was_not_ suggesting that
exceptions should be throwable in the middle of pure computations.
So ioError should have type
IOError -> IO a
just as it does now, the only change would be that IOError is the
same sort of animal as SML's exn type. Would this break anything?
I would really find this a much more useful extension than being
able to throw exceptions from anywhere.