19 Aug
2002
19 Aug
'02
10:41 p.m.
On Mon, Aug 19, 2002 at 11:19:41PM +0200, Jan Kybic wrote:
Hello, I am wrestling with having Haskell (using ghc(i) version 5.02.2) evaluate things in good order and to garbage collect what he no longer needs. I could simplify the problem to this simple example:
main = print $ sum [0..1000000]
When you use a sufficiently large number (perhaps 10000000 instead of 1000000), both ghci and ghc terminate with "Stack space overflow". On the other hand, Hugs (dated December 2001) runs the example OK and produces the result of 500000500000.
ghc -O2 seems to run the program above in constant space. I guess strictness analysis (which knows how to evaluate the foldl) only happens at -O2 or above? Best, Dylan Thurston