Hi I am trying to write criterion benchmarks for the pretty library. Unfortunately, building the benchmark executable fails at some point during the development with the following error message:
---8<--- <command line>: cannot satisfy -package-id pretty-1.1.1.1-inplace: pretty-1.1.1.1-inplace is shadowed by package pretty-1.1.1.1-7bd0114e9691fca3d3447fc0133701cf --->8--- I don't understand the cause of the error, let alone what I am supposed to do next. Any help is much appreciated. Here are the steps that lead to the above quoted error. Sorry, if this is not the smallest counter example possible. As I said, I hardly understand what is going on. (the two patch files mentioned are attached to this email, virthualenv is version 0.2.1) ---8<--- git clone https://github.com/haskell/pretty.git cd pretty git apply /tmp/0001-hello-world-setup.patch export PATH=/opt/ghc-7.4.2/install/bin:/opt/haskell-platform-2012.4.0.0/install/bin:$PATH ~/.cabal/bin/virthualenv source .virthualenv/bin/activate cabal configure --user cabal build cabal install cabal install criterion cabal configure --user --enable-benchmarks cabal build git apply /tmp/0002-replaced-example-with-real-benchmark.patch cabal install language-c cabal configure --user --enable-benchmarks cabal build # error --->8--- So the first build of the benchmark executable works, but the second one "suddenly" fails. Executing "cabal build -v" next yields ---8<--- $ cabal build -v creating dist/build creating dist/build/autogen Building pretty-1.1.1.1... Preprocessing library pretty-1.1.1.1... Building library... creating dist/build /opt/ghc-7.4.2/install/bin/ghc --make -package-name pretty-1.1.1.1 -hide-all-packages -fbuilding-cabal-package -package-conf /home/alex/tmp/pretty/.virthualenv/ghc_pkg_db -i -idist/build -isrc -idist/build/autogen -Idist/build/autogen -Idist/build -optP-include -optPdist/build/autogen/cabal_macros.h -odir dist/build -hidir dist/build -stubdir dist/build -package-id base-4.5.1.0-66f22db3dfcd87541c9c7e50e7095d26 -O -Wall -fwarn-tabs -XHaskell98 -XCPP -XBangPatterns Text.PrettyPrint Text.PrettyPrint.HughesPJ Linking... /usr/bin/ar -r dist/build/libHSpretty-1.1.1.1.a dist/build/Text/PrettyPrint.o dist/build/Text/PrettyPrint/HughesPJ.o /usr/bin/ar: creating dist/build/libHSpretty-1.1.1.1.a /usr/bin/ld -x --hash-size=31 --reduce-memory-overheads -r -o dist/build/HSpretty-1.1.1.1.o dist/build/Text/PrettyPrint.o dist/build/Text/PrettyPrint/HughesPJ.o Registering pretty-1.1.1.1... /opt/ghc-7.4.2/install/bin/ghc-pkg update - --global --user --package-conf=/home/alex/tmp/pretty/.virthualenv/ghc_pkg_db --package-conf=dist/package.conf.inplace Preprocessing benchmark 'bench-pretty' for pretty-1.1.1.1... Building benchmark bench-pretty... creating dist/build/bench-pretty creating dist/build/bench-pretty/bench-pretty-tmp /opt/ghc-7.4.2/install/bin/ghc --make -o dist/build/bench-pretty/bench-pretty -hide-all-packages -fbuilding-cabal-package -package-conf /home/alex/tmp/pretty/.virthualenv/ghc_pkg_db -package-conf dist/package.conf.inplace -i -idist/build/bench-pretty/bench-pretty-tmp -ibench -idist/build/autogen -Idist/build/autogen -Idist/build/bench-pretty/bench-pretty-tmp -optP-include -optPdist/build/autogen/cabal_macros.h -odir dist/build/bench-pretty/bench-pretty-tmp -hidir dist/build/bench-pretty/bench-pretty-tmp -stubdir dist/build/bench-pretty/bench-pretty-tmp -package-id base-4.5.1.0-66f22db3dfcd87541c9c7e50e7095d26 -package-id criterion-0.6.2.1-5ae981935ea0c9773e0df464b5922b27 -package-id language-c-0.4.2-fe58279e43af097994ce7b7010785c69 -package-id pretty-1.1.1.1-inplace -O -O -XHaskell98 bench/Bench.hs <command line>: cannot satisfy -package-id pretty-1.1.1.1-inplace: pretty-1.1.1.1-inplace is shadowed by package pretty-1.1.1.1-7bd0114e9691fca3d3447fc0133701cf (use -v for more information) --->8--- What does this mean? What am I doing wrong? How can I fix this? Greetings, Alex
From 913a4510523dac316ace5d35909f65c95e694153 Mon Sep 17 00:00:00 2001 From: Alexander Bernauer <a...@copton.net> Date: Sat, 2 Feb 2013 21:16:48 +0100 Subject: [PATCH 1/2] hello world setup --- bench/Bench.hs | 14 ++++++++++++++ pretty.cabal | 13 ++++++++++++- 2 files changed, 26 insertions(+), 1 deletions(-) create mode 100644 bench/Bench.hs diff --git a/bench/Bench.hs b/bench/Bench.hs new file mode 100644 index 0000000..5d33ecd --- /dev/null +++ b/bench/Bench.hs @@ -0,0 +1,14 @@ +module Main where + +import Criterion.Main + +fib :: Int -> Int +fib 0 = 0 +fib 1 = 1 +fib n = fib (n-1) + fib (n-2) + +main = defaultMain [ + bench "fib 10" $ nf fib 10 + , bench "fib 30" $ nf fib 30 + , bench "fib 35" $ nf fib 35 + ] diff --git a/pretty.cabal b/pretty.cabal index cdab4c0..d4e522e 100644 --- a/pretty.cabal +++ b/pretty.cabal @@ -1,5 +1,5 @@ name: pretty -version: 1.1.1.0 +version: 1.1.1.1 synopsis: Pretty-printing library description: This package contains a pretty-printing library, a set of API's @@ -47,6 +47,17 @@ Test-Suite test-pretty extensions: CPP, BangPatterns include-dirs: src/Text/PrettyPrint +Benchmark bench-pretty + type: exitcode-stdio-1.0 + main-is: Bench.hs + build-depends: + base >= 3 && < 5, + criterion == 0.6.*, + pretty + + hs-source-dirs: bench + ghc-options: -O + -- Executable Bench1 -- main-is: Bench1.hs -- hs-source-dirs: test -- 1.7.1
From ebd0acd79c2ed1f2cdd6a07dc0e7ec3b89658827 Mon Sep 17 00:00:00 2001 From: Alexander Bernauer <a...@copton.net> Date: Mon, 4 Feb 2013 22:05:35 +0100 Subject: [PATCH 2/2] replaced example with real benchmark --- bench/Bench.hs | 40 ++++++++++++++++++++++++++++------------ pretty.cabal | 1 + 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/bench/Bench.hs b/bench/Bench.hs index 5d33ecd..6f25d1d 100644 --- a/bench/Bench.hs +++ b/bench/Bench.hs @@ -1,14 +1,30 @@ module Main where -import Criterion.Main - -fib :: Int -> Int -fib 0 = 0 -fib 1 = 1 -fib n = fib (n-1) + fib (n-2) - -main = defaultMain [ - bench "fib 10" $ nf fib 10 - , bench "fib 30" $ nf fib 30 - , bench "fib 35" $ nf fib 35 - ] +import Criterion.Config (defaultConfig) +import Criterion.Main (defaultMainWith, bench, nf, parseArgs, defaultOptions) +import System.Environment (getArgs) +import Text.PrettyPrint.HughesPJ (render) + +import Language.C (parseCFile) +import Language.C.Syntax.AST (CTranslUnit) +import Language.C.Data (initPos) +import Language.C.Pretty (pretty) +import Language.C.System.GCC (newGCC) + +import qualified Data.ByteString.Char8 as BS + +parse :: FilePath -> IO CTranslUnit +parse fp = do + out <- parseCFile (newGCC "gcc") Nothing ["-I."] fp + case out of + Left e -> error (show e) + Right x -> return x + +main = do + args <- getArgs + (config, files) <- parseArgs defaultConfig defaultOptions args + print files + tus <- mapM parse files + let docs = map pretty tus + let bs = zipWith (\f d -> bench f $ nf render d) files docs + defaultMainWith config (return ()) bs diff --git a/pretty.cabal b/pretty.cabal index d4e522e..47b1c35 100644 --- a/pretty.cabal +++ b/pretty.cabal @@ -53,6 +53,7 @@ Benchmark bench-pretty build-depends: base >= 3 && < 5, criterion == 0.6.*, + language-c == 0.4.*, pretty hs-source-dirs: bench -- 1.7.1
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe