[Haskell-cafe] Two-iteration optimisation (was: GHC Predictability)

Yitzchak Gale gale at sefer.org
Thu May 15 05:17:43 EDT 2008

Don Stewart wrote:
> You'd want a general fusion framework for this...
> Stream fusion... at least does this for zips...
> but for an arbitrary 'f' instead of zip,
> seems harder.

And of course, you wouldn't want that:

f xs = xs : map expensiveCalculation xs

Please don't fuse those two loops into one.

In the case of "mean", the outer function in question
is /, and that is a good candidate for fusion because
it is strict in both arguments.

I think Don is right. There is a lot of room for expanding
the scope of fusion, but it needs to be done one function
at a time until our strictness analysis gets better.

In the general case, I like the way things work now. The original
complaint about "unpredictability" is, in my opinion,
a "bug in the documentation". This is yet another concept
whose basics need to be made much more accessible to


More information about the Haskell-Cafe mailing list