Replaced throw to throwIO where type is IO
Bas van Dijk
v.dijk.bas at gmail.com
Sat Sep 25 11:12:21 EDT 2010
On Sat, Sep 25, 2010 at 4:41 PM, Bas van Dijk <v.dijk.bas at gmail.com> wrote:
> 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))
I think I found the answer myself.
I see that raiseIO# is implemented as jumping to the implementation of raise#:
rts/Exception.cmm line: 588
/* Args :: R1 :: Exception */
So I guess using #raise directly is faster since it doesn't need to
perform the jump.
I'll see if I can make some Criterion benchmarks to see if it's actually faster.
More information about the Libraries