Wed, 29 Aug 2001 17:33:10 +0100
> On Tue, 28 Aug 2001, Simon Marlow wrote:
> > In GHC, you can do this:
> > import Exception
> > do result <- catch (evaluate (read "foo" :: Int))
> > (\error -> ... )
> I do like that. Is it likely to become standard someday, do you think?
> Errors like this should certainly be catchable in such a way;=20
> I was sad
> when I was first looking into this and found that 'catch' seemed to be
> inextricably linked to IO.
Well, we'd like it to become standard :-) The exception stuff is really
very easy to implement - you just use the standard stack-unwinding
implementation of throw, and catch has to push a special stack frame.
GHC's asynchronous exceptions are slightly harder, but I don't think it
was more than a day or two's work. =20
As a bonus you get to use a more efficient implementation of the IO
monad, because it doesn't have to deal explicitly with exceptions. And
then IO becomes a straightforward instance of ST.
I guess I should also document the Exception extension in a self
contained way, similar to the way the FFI extension is documented.