In Haskell the foldl’ function defined in the module Data.List is better than foldl because that does not use a thunk
. A thunked expression requires an internal stack. As an expression can grow infinitely large, the runtime imposes a limit on the size of this stack. As the simple example below shows that given a large enough input the stack will overflow.