[Haskell-cafe] Sub-optimal [code]
batterseapower at hotmail.com
Thu Feb 17 00:09:14 CET 2011
On 16 February 2011 22:48, Daniel Fischer
<daniel.is.fischer at googlemail.com> wrote:
> The problem with that is that under certain circumstances the list is
> shared in nested loops, which was what caused the thread (it was mapM_ and
> not forM_, but I'd be very surprised if they behaved differently with -O2).
Yep - d'oh!
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.
More information about the Haskell-Cafe