The answer is sometimes (only if you use an optimize flag): ke...@sugarglider:~/temp/> cat sumtest.hs main = putStrLn . show . sum $ [0 .. 1000000] ke...@sugarglider:~/temp/> ghc --make sumtest.hs [1 of 1] Compiling Main ( sumtest.hs, sumtest.o ) Linking sumtest ... ke...@sugarglider:~/temp/> ./sumtest Stack space overflow: current size 8388608 bytes. Use `+RTS -Ksize' to increase it. ke...@sugarglider:~/temp/> rm sumtest.hi sumtest.o sumtest ke...@sugarglider:~/temp/> ghc --make -O2 sumtest.hs [1 of 1] Compiling Main ( sumtest.hs, sumtest.o ) Linking sumtest ... ke...@sugarglider:~/temp/> ./sumtest 500000500000 ke...@sugarglider:~/temp/> ghc --version The Glorious Glasgow Haskell Compilation System, version 6.10.1
But since hackage warns against using these flags when you upload packages I would think that most libraries would not be using a strict version of sum. On Mon, Jun 15, 2009 at 11:14 AM, Don Stewart<[email protected]> wrote: > keithshep: >> Is there any reason that sum isn't strict? I can't think of any case >> where that is a good thing. >> >> Prelude> sum [0 .. 1000000] >> *** Exception: stack overflow >> > > It is strict when subject to strictness analysis (try compiling it). > > -- Don > > > -- keithsheppard.name _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
