
25 Sep
2010
25 Sep
'10
3:12 p.m.
On Sat, Sep 25, 2010 at 4:41 PM, Bas van Dijk
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 stg_raiseIOzh { /* Args :: R1 :: Exception */ jump stg_raisezh; } 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. Bas