I have the following code.
main = print $ sum [1..1000000]
When I run I get a stack overflow:
Stack space overflow: current size 8388608 bytes.
Use `+RTS -Ksize -RTS' to increase it.
I'm accustom to imperative languages like Python which seem to have no problem with such a calculation:
sum(range(100000000)) # I'm not even using a generator.
4999999950000000
Haskell is obviously different, but I don't quite understand what's happening to cause the stack overflow? What's going on under the hood to cause the stack overflow in Haskell?