<div dir="ltr"><div>As Duncan Coutts explains toward the end of <a href="http://www.well-typed.com/blog/90/" target="_blank">http://www.well-typed.com/blog/90/</a> (which proposes something else I personally *don't* endorse), foldl', the strict foldl, isn't actually strict enough. In particular, it's only conditionally strict in the initial value for the accumulator:<br><br></div><div>foldl' (\_ x -> x) undefined [3] = 3<br><br><br></div><div>Why does this matter? Strictness analysis needs to look at (and be able to look at) the function passed to foldl' to determine whether the expression is strict in the initial value. foldl'-as-foldr tends to complicate this sort of analysis already.<br><br></div><div>Proposal: make foldl' unconditionally strict in the initial accumulator value, both in GHC.List and in (the default definition in) Data.Foldable, and make foldr' in Data.Foldable unconditionally strict in the initial value of its accumulator.<br><br></div><div>Specifically,<br><br>foldl' k z0 xs =<br>  foldr (\v fn z -> z `seq` fn (k z v)) id xs z0<br><br></div><div>would change to<br><br>foldl' k !z0 xs = <br>  foldr (\v fn z -> z `seq` fn (k z v)) id xs z0<br><br></div></div>