So I have the following code from Preventing caching of computation in Criterion benchmark and my aim is to be able to step from main
directly into the function defaultMain
in Criterion.Main
:
{-# OPTIONS -fno-full-laziness #-}
{-# OPTIONS_GHC -fno-cse #-}
{-# LANGUAGE BangPatterns #-}
module Main where
import Criterion.Main
import Data.List
num :: Int
num = 100000000
lst :: a -> [Int]
lst _ = [1,2..num]
myadd :: Int -> Int -> Int
myadd !x !y = let !result = x + y in
result
mysum = foldl' myadd 0
main :: IO ()
main = defaultMain [
bgroup "summation"
[bench "mysum" $ whnf (mysum . lst) ()]
]
and the cabal file is :
name: test
version: 0.1.0.0
build-type: Simple
cabal-version: >=1.10
executable test
main-is: Main.hs
build-depends: base >=4.8 && <4.9,
criterion==1.1.0.0
default-language: Haskell2010
ghc-options: "-O3"
(using ghc 7.10.1 and cabal 1.22.0.0).
If from within cabal repl
I try to set a breakpoint in criterion I get the following error :
*Main> :break Criterion.Main.defaultMain
cannot set breakpoint on defaultMain: module Criterion.Main is not interpreted
Furthermore if I try to add
the package I get the following error :
*Main> :add *Criterion
<no location info>: module ‘Criterion’ is a package module
Failed, modules loaded: Main.
If I do within the directory git clone https://github.com/bos/criterion
and then add the following two lines to my cabal file :
other-modules: Criterion
hs-source-dirs: .
./criterion
then upon doing cabal build
I get the following errors :
criterion/Criterion/IO.hs:23:0:
error: missing binary operator before token "("
#if MIN_VERSION_binary(0, 6, 3)
so I suspect that I have to do a full on merge of the criterion cabal file with my cabal file above, which feels a bit excessive.
Is there an easier way for me to go about setting a breakpoint in Criterion, so that I can step (when debugging in cabal repl/ghci) directly from my source into criterion's source? Thanks
p.s. There is a related question at Debugging IO in a package module inside GHCi but unfortunately it did not help.