sum1, -O
S.D.Mechveliani
mechvel at math.botik.ru
Mon May 28 07:46:04 EDT 2001
Please, what is the matter here with ghc-5.00.1
(compiled from source for Linux i386-unknown) ?
----------------------
sum1 :: (Num a) => [a] -> a
sum1 [] = error "sum1 []\n"
sum1 (x:xs) = sm xs x where sm [] s = s
sm (x:xs) s = sm xs (x+s)
main = putStr ""
----------------------
ghc -c -O Main.hs
ghci +RTS -M70m -RTS
...
Main> sum1 [1 .. 1999000]
GHC's heap exhausted; ...
----------------------
Now, if we change it to
...
main = putStr $ shows (sum1 [1 .. 1999000]) "\n"
,
recompile, then it yields
ghci +RTS -M70m -RTS
...
Main> main
1998001499500
-----------------
Serge Mechveliani
mechvel at botik.ru
More information about the Glasgow-haskell-bugs
mailing list