[Haskell-cafe] missing optimization for (++)

Li-yao Xia lysxia at gmail.com
Mon Mar 5 12:40:48 UTC 2018


On 03/05/2018 07:13 AM, Ben Franksen wrote:
> Okay, okay, I got it. I did not think about strictness when I asked. The
> funny thing is that the two fusion rules combined, as explained by
> Josef, seem to cause this shortcut to be taken. But that can't be true
> because (++) really is non-strict, I tested that, with -O2. How do you
> explain that?

Rewrite rules apply at compile time and don't force any computation.
The second rule fires only if the second argument of (++) is 
syntactically []. Otherwise the code doesn't change, and strictness is 
preserved.

Cheers,
Li-yao


More information about the Haskell-Cafe mailing list