sum[1..100000] --> stack overflow in GHC, but not in Hugs?

Vishal Belsare shoot.spam at
Sun Nov 23 09:07:19 EST 2008


Please bear with a very basic question. I am trying to 'learn me a
Haskell for great good' using Hutton's book and some online tutorials.
I started off with Hugs and recently used GHC (to use the 'let a  =
.." syntax interactively, which Hugs doesn't allow perhaps).

There's a simple issue I am having with GHC. sum[1..100000] works fine
on Hugs, however, the same in GHCi generates a stack overflow
exception. I am trying to figure out what's going on.

Prelude> sum[1..100000]
Prelude> sum[1..1000000]
*** Exception: stack overflow


Hugs> sum[1..10000]
Hugs> sum[1..100000]

Thanks in anticipation.

Best regards,
Vishal Belsare

ps: please excuse if the question is too uncool for the list. I come
from an economics background; the markets are bad, I am depressed and
to add to my pain, GHC refuses to let me know sum[1..100000]

Firstly, I propose for myself the rule that the obviousness of a
proposition does not free me from the obligation to continue searching
for a proof of it, at least until I clearly realize that absolutely no
proof could ever be required, and why.

~ Bernhard Bolzano

More information about the Glasgow-haskell-users mailing list