[Haskell-cafe] Sub-optimal [code]

Andrew Coppin andrewcoppin at btinternet.com
Sun Feb 20 16:10:16 CET 2011


On 16/02/2011 11:09 PM, Max Bolingbroke wrote:

> Thinking about it some more, this example is actually quite
> interesting because if you *prevent* the list from being floated the
> forM gets foldr/build fused into a totally listless optimal loop. It
> really does seem like a shame to disable that optimisation because of
> the floating... if only the fusion hit before float-out was run.

It seems to me that in this case, I'm using a list when what I actually 
"mean" is a stream. (Here "stream" refers to the construct used in the 
stream-fusion package.) I can't actually *want* a physical data 
structure to be constructed - so why am I asking for one?

It sems to me that lots of Haskell code uses lists where it actually 
means streams... The stream-fusion package uses streams to fuse together 
list operations, but I rather suspect it would be cleaner and more 
helpful if people wrote code explicitly in terms of streams in the first 
place, except for the small minority of places where you really do want 
an actual list.

But that's just my opinion...



More information about the Haskell-Cafe mailing list