Criterion fails when running in ghci

116 Views Asked by At

I want to track the difference of time for termination of the following to versions calculating the length of a list. I have got one recursive and one tail recursive. Somehow i have got a problem when running in ghci (See below)

-- 4-1 a) Laenge einer Liste --
import Criterion.Main

main :: IO ()
main = defaultMain [
  bgroup "myList" [ bench "1" $ whnf myList [1]
                 , bench "2" $ whnf myList [1,2]
                 , bench "3" $ whnf myList [1,2,3]
                 , bench "4" $ whnf myList [1,2,3,4]
                 , bench "10" $ whnf myList [1,2,3,4,5,6,7,8,9,10]
                 , bench "20" $ whnf myList [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
                ]
  bgroup "myListner" [ bench "1" $ whnf myListner [1]
                  , bench "2" $ whnf myLister [1,2]
                  , bench "3" $ whnf myListner [1,2,3]
                  , bench "4" $ whnf myListner [1,2,3,4]
                  , bench "10" $ whnf myListner [1,2,3,4,5,6,7,8,9,10]
                  , bench "20" $ whnf myListner [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
                  ]
]


--endrekursiv
myList:: [a]->Integer
myList []=0
myList (x:xs)= myHelpList 1 xs 
 where
  myHelpList:: Integer-> [a]->Integer
  myHelpList acc [] = acc
  myHelpList acc (x:xs) = myHelpList (acc+1) xs

--nicht endrekursiv
myListner::[a]->Integer
myListner []=0
myListner (x:xs)= 1+ myList xs

Ghci returns:

laenge.hs:3:8:
Could not find module ‘Criterion.Main’
Use -v to see a list of the files searched for.

Failed, modules loaded: none.
Prelude>

Can anyone help me with that?

0

There are 0 best solutions below