foldr/nil rule not applied consistently
I just had a project where it made a difference whether I add
{-# RULES "foldr/nil" forall k n . GHC.Base.foldr k n [] = n #-}
to my file or not, despite this rule already being present in the library.
I tried to minimize the problem and came up with this:
foo1 (f, fs) (x, xs) = (f x, map ($x) fs ++ map f xs)
foo2 f fs x xs = (f x, map ($x) fs ++ map f xs)
test1 x xs = foo1 (id, []) (x, xs)
test2 x xs = foo2 id [] x xs
test3 x xs = (id x, map ($x) [] ++ map id xs)
test2 and test3 nicely optimize the map … [] ++ away, but test does not.
(In this minimized example, adding the rule again locally does *not* help, but there is still something fishy.)
Also, in all cases, map id remains, which should not be the case.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 8.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |