
Josef Svenningsson wrote:
On 4/10/06, Malcolm Wallace
wrote: Are the larger sizes of zipWith (zipWith3, zipWith4, ...) also good producers? I have some evidence from a recent application I have been writing that they may not be. At least, reading the -ddump-simpl output, it does not seem clear-cut that a pipeline e.g. (concat . f . map g . zipWith3 h as bs) cs is turned into a simple loop, although perhaps I am not reading it right. Is there any received wisdom on what should be expected here?
The GHC documentation is rather clear at this point. See: http://www.haskell.org/ghc/docs/latest/html/users_guide/rewrite-rules.html#i...
The larger zipWiths are not listed as good producers, hence you cannot expect fusion to happen.
Thanks for the pointer, I wasn't aware of that :) In fact, I recently added RULEs for deforesting take, so I need to add it to that list. I don't see any good reason why the larger zipWiths cannot be good producers, it just needs somebody to write the RULEs and check that they work. The tricky bit is usually making sure that the foldr/build versions (just build in this case) revert to the efficient variant in the event that fusion doesn't happen. Cheers, Simon