Typing following into GHCI on Windows:
foldl (+) 0 $ take 100000000 $ map sqrt [1..]
gives:
<interactive>: out of memory
while compiling (with GHC) and running this program:
main = do
let score = foldl (+) 0 $ take 100000000 $ map sqrt [1..]
putStrLn $ show score
prints expected answer without memory error.
Is there a reason for this behavior ? It seems to me like laziness of Haskell should prevent this one liner from crashing.