<div dir="ltr">Right, these optimizations are done on the unboxed level, where bottom is not a concern. GHC would transform<div><br></div><div>bar a b = a + b - a - b</div><div><br></div><div>to</div><div><br></div><div>bar (I# a) (I# b) = I# (a +# b -# a -# b)</div>
<div><br></div><div style>whose RHS could be optimized away to I# 0#. bar is still strict in its two arguments, so calling bar undefined undefined would still throw an error.</div><div style><br></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Sun, Jun 2, 2013 at 7:24 AM, Boris Lykah <span dir="ltr">&lt;<a href="mailto:lykahb@gmail.com" target="_blank">lykahb@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>It is not obvious that semantics is preserved for optimisations which remove non-constants like</div><div class="im"><div><br></div><div>bar a b = a + b - a - b -- the RHS is should be optimized away to 0<br></div><div>
<br></div></div><div>
Calling bar undefined undefined throws an error, but the optimised bar would return 0.</div><div class="HOEnZb"><div class="h5"><br></div></div><span class="HOEnZb"><font color="#888888">-- <br>Regards,<br>Boris
</font></span></blockquote></div><br></div></div>