[Haskell-cafe] Stream fusion

Roman Leshchinskiy rl at cse.unsw.edu.au
Fri Nov 18 16:36:28 CET 2011


Yves Parès wrote:
>
> While re-reading RealWorldHaskell, chapter 25, I saw that -- unlike I
> believed -- loop fusion wasn't activated by default under GHC for lists
> (but that module Data.List.Stream from package stream-fusion could provide
> it).

Note that stream fusion is only one way to do fusion. For lists, GHC uses
foldr/build fusion which is a different approach but still fuses loops.
You get this by default when compiling with optimisations.

> Is that still the case? If not, then are there some cases of list
> processing where loop fusion would be a bad thing? (Ergo cases where you
> should stick to Prelude/Data.List functions and not use Data.List.Stream
> implementation)

I'm not sure if anybody has actually benchmarked the stream-fusion package
with a modern GHC. I suspect it wouldn't hold up well, too many things
have changed in the compiler since it was written. So I'm not really sure
you should be using it at all. Chances are, if you really care about
having tight loops you shouldn't be using lists at all.

Roman






More information about the Haskell-Cafe mailing list