Why no stack overflow in ghci?

Roman Cheplyaka roma at ro-che.info
Tue Jul 26 21:57:53 CEST 2011

The code

  main = print $ foldl (+) 0 [1..1000000]

when compiled (without optimizations) results in a stack overflow, which
is expected.

However, when run from ghci it succeeds. Why is it so?
(Tested with GHC 6.12.something and 7.0.4)

Is it related to "stack-squeezing"? I couldn't find any description of
it, apart from a few bug reports.

A related question: how can I control the stack size in evaluations
inside ghci? Is it (roughly) the same as setting the ghci's own stack
size by passing -K to it in the command line?

Roman I. Cheplyaka :: http://ro-che.info/

More information about the Glasgow-haskell-users mailing list