Right, these optimizations are done on the unboxed level, where bottom is
not a concern. GHC would transform

bar a b = a + b - a - b

to

bar (I# a) (I# b) = I# (a +# b -# a -# b)

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.



On Sun, Jun 2, 2013 at 7:24 AM, Boris Lykah <lyk...@gmail.com> wrote:

> It is not obvious that semantics is preserved for optimisations which
> remove non-constants like
>
> bar a b = a + b - a - b -- the RHS is should be optimized away to 0
>
> Calling bar undefined undefined throws an error, but the optimised bar
> would return 0.
>
> --
> Regards,
> Boris
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to