1 Answer
1

It's just GHC doing strictness and other optimizations. GHCi doesn't do the same sort of optimizations that the full compiler does.

In particular that foldl is building up way too many thunks and those are causing your overflow. However when I change this to the strict foldl' even GHCi can handle it. You should read this question to learn a bit more about why this is.