On Thu, Dec 18, 2008 at 1:53 AM, Cetin Sert <cetin.sert@gmail.com> wrote:
>
> Hi,
>
> I tested the following, why does the rewrite rules not fire when using tuples also in testRewrite2, testRewriteReverse2?
testRewrite2 :: a → (Bool,Bool)
testRewrite2 x = (pf,pi)
where
f = replicate 2000 x
i = repeat x
lf = length f
li = length i
pf = lf > 300
pi = li > 300
Why would you expect it to? The compiler is free to inline lf and li to discover that the rule applies, but it is also free not to. Applying all applicable rules while maintaining the ability to abstract is undecidable (big surprise). Thus the dependency on compiler cleverness I mentioned...
There might be something you can do with rule ordering, make sure it happens after the inlining phase, but I don't know how to do that offhand.
Luke