There are lots of good questions and answers about foldl
, foldr
, and foldl\'
in Haskell.
So now I know that:
1) foldl<
The short answer is that in foldl f
, it's not necessarily the case that f
is strict, so it might be too eager to reduce the thunks up front. However, in practice it usually is, so you nearly always want to be using foldl'
.
I wrote a more in-depth explanation of how the evaluation order of foldl and foldl' works on another question. It's rather long but I think it should clarify things a bit for you.