simple program crash (GHC 5.02, Hugs)

Oleg Galbert OlegG@amdocs.com
Fri, 21 Dec 2001 16:22:42 -0600


I'm a newbie in Haskell. 
I tryed to compare performance of GHC compiled code and Ocaml compiled code
on a small example:

test n cosx
        | n==0 = cosx
        | otherwise = test (n-1) (cosx+cos(cosx))

main = print ( test  10000000 0.0 )  

I compiled it on Win NT :

ghc -o test_haskell.exe test_haskell.hs
     
When I run the program I got the following message:

Stack space overflow: current size 1048576 bytes.
Use `+RTS -Ksize' to increase it.

Hugs 98 (December 2001) version just fails with "Application Error" message.

Does a stack usage depends on number of recursive calls? Is there a tail
recursion optimization?

In Ocaml version of this program everything goes well.
The program produced the result without any complains.

Oleg Galbert