Skip to content

Commit 3dfa717

Browse files
committed
Complete example of stackoverflow.hs
1 parent 12644b7 commit 3dfa717

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed
Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
1-
-- The result of this example doesn't change whether with or without Strict.
21
{-
32
stack exec ghc -- -O0 -rtsopts -with-rtsopts=-K1k ./stackoverflow.hs
43
stack exec ghc -- -O0 -rtsopts -with-rtsopts=-K1k -XStrict ./stackoverflow.hs
4+
stack exec ghc -- -O1 -rtsopts -with-rtsopts=-K1k ./stackoverflow.hs
5+
stack exec ghc -- -O1 -rtsopts -with-rtsopts=-K1k -XStrict ./stackoverflow.hs
56
-}
67

78
import Control.Exception
9+
import Data.List
810

911
main :: IO ()
1012
main = do
11-
let size = 50000
12-
evaluate $ foldr (\x z -> x : z) [] [1 .. size]
13-
putStrLn "DONE: foldr"
13+
let size = 5000
14+
putStrLn "BEGIN"
15+
16+
evaluate $ foldr (:) [] [1 .. size]
17+
putStrLn "DONE: foldr 1"
18+
1419
evaluate $ foldl (\z x -> x : z) [] [1 .. size]
1520
putStrLn "DONE: foldl"
21+
22+
evaluate $ foldr (\x z -> x : z) [] [1 .. size]
23+
putStrLn "DONE: foldr 2"

0 commit comments

Comments
 (0)