Replaced throw to throwIO where type is IO

Bas van Dijk v.dijk.bas at
Sat Sep 25 10:41:37 EDT 2010

On Sat, Sep 25, 2010 at 2:54 PM, Ian Lynagh <igloo at> wrote:
> Thanks for your work on this. Please see
> for the process to propose changes to the core libraries.

Yes, I know the process. However, consider my mail more as a question
if the current use of throw is always equivalent to using throwIO.

Take the current onException as an example:

onException io what = io `catch` \e -> do _ <- what
                                          throw (e :: SomeException)

is this always equivalent to:

onException io what = io `catch` \e -> do _ <- what
                                          throwIO (e :: SomeException)

? Thinking about this some more I can't seem to find a situation where
the two are different. So my patch can safely be ignored and I
apologize for the noise.

However I do wonder why onException is using throw instead of the
recommended throwIO. Has this to do with performance since they're
both primitive operations:

throw :: Exception e => e -> a
throw e = raise# (toException e)

throwIO :: Exception e => e -> IO a
throwIO e = IO (raiseIO# (toException e))




More information about the Libraries mailing list