Adding scanl'

Niklas Hambüchen mail at
Fri Sep 14 02:03:18 CEST 2012

> Yes, because sum is defined in the Report as using foldl. This is silly,
> but it is what it is. With optimizations on, GHC often converts foldl
> into foldl' (when it's semantics-preserving) because of this and other
> functions which "must" use foldl.

I see. This, though, sounds like an argument for scanl' for me, so that
I don't have to rely on it doing optimisations like this "often" (in
last . scanl, it obviously doesn't), and not to have the usefulness of
my library hovering between fast/constant-memory and eats-all-my-ram
based on the hope that -O guesses what I want (doesn't work in ghci, of
course) *and* that the user knows how I construct my lists internally.

More information about the Libraries mailing list