blob: 9f615da9eddbcf993709fff5e35d0c1b9d42bc96 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
{-# LANGUAGE DeriveFunctor, DeriveFoldable #-}
module Main where
import Prelude hiding (foldr)
import Data.Foldable
data List a = Nil | Cons a (List a)
deriving (Functor, Foldable)
mkList :: Int -> List Int
mkList 0 = Nil
mkList n = Cons n (mkList (n-1))
main :: IO ()
main = print $ foldr (\x y -> y) "end" (mkList n)
where n = 40000
-- Increase this to increase the difference between good and bad
-- Eg 6000 takes a lot longer
-- The biggest difference is not allocation or bytes used,
-- but execution time!
|