3 ms·
sum is fine in GHC. It is specialised for Integer. GHCi uses naive sum though.
by dons 13y ago
sum is fine in GHC. It is specialised for Integer. GHCi uses naive sum though.
- tsahyt 13y agoGood to know that. I was trying that code in GHCi, which explains a few things now.
- cgag 13y agoI tried sum in GHC and it ate up my 16 gigs of ram and then crashed. I'm a noob so maybe I did something wrong, but my code was: main = do putStrLn $ show $ sum [1..1000000000]
- TheCoelacanth 13y agoPass GHC the -O2 option to turn on optimizations. You need the strictness analyzer to run so that it can determine that sum is strict, otherwise you get a space leak.
- cgag 13y agoThank you :)