Re: [Haskell-cafe] Re: Don't “accidentallyparallelize”

David Menendez dave at zednenem.com
Sun Sep 6 02:18:31 EDT 2009


On Sat, Sep 5, 2009 at 7:57 PM, Dan Doel<dan.doel at gmail.com> wrote:
>
> I suppose technically, what foldl' has over foldl is that it is more readily
> subject to optimization. Each recursive call is artificially made strict in
> the accumulator, so it is legal for GHC to optimize the function by keeping
> the accumulator evaluated, instead of delaying it. When GHC is run with
> optimizations on, it does analysis on all code that tries to determine such
> things, and seq can be seen as making such analysis easier for the compiler.

It turns out, pseq limits the effectiveness of strictness analysis,
because it forces the order of evaluation. John Meacham described this
pretty well last week in the Haskell' list
<http://www.haskell.org/pipermail/haskell-prime/2009-August/003006.html>.

> This is, of course, not what really happens in GHC. What really happens is
> that the first argument to seq is evaluated before the second (which is why it
> even has the intended effect when optimizations aren't on). But that doesn't
> have to be the case, strictly speaking.

It's entirely possible for optimized code to end up evaluating the
second argument to seq before the first.

-- 
Dave Menendez <dave at zednenem.com>
<http://www.eyrie.org/~zednenem/>


More information about the Haskell-Cafe mailing list