我正在使用cabal-3.0.0.0
构建一个非常简单的可执行文件:
-- 2019/day/5/part1.hs
module Main where
import Test.DocTest (doctest)
main :: IO ()
main = do
doctest ["2019/day/5/part1.hs"]
return ()
在我的cabalfile文件中:
-- advent-of-code.cabal
-- ...
executable day5-part1
main-is: 2019/day/5/part1.hs
build-depends: base, doctest
default-language: Haskell2010
它构建良好:
➤ cabal --version
cabal-install version 3.0.0.0
compiled using version 3.0.0.0 of the Cabal library
➤ cabal build day5-part1
Resolving dependencies...
Build profile: -w ghc-8.6.5 -O1
In order, the following will be built (use -v for more details):
- advent-of-code-0.1.0.0 (exe:day5-part1) (first run)
Configuring executable 'day5-part1' for advent-of-code-0.1.0.0..
Preprocessing executable 'day5-part1' for advent-of-code-0.1.0.0..
Building executable 'day5-part1' for advent-of-code-0.1.0.0..
[1 of 1] Compiling Main ( 2019/day/5/part1.hs, /Users/rampion/Projects/AdventOfCode2019/dist-newstyle/build/x86_64-osx/ghc-8.6.5/advent-of-code-0.1.0.0/x/day5-part1/build/day5-part1/day5-part1-tmp/Main.o )
Linking /Users/rampion/Projects/AdventOfCode2019/dist-newstyle/build/x86_64-osx/ghc-8.6.5/advent-of-code-0.1.0.0/x/day5-part1/build/day5-part1/day5-part1 ...
但是在运行时失败:
➤ cabal run day5-part1
Up to date
2019/day/5/part1.hs:2:1: error:
Could not find module ‘Test.DocTest’
Use -v to see a list of the files searched for.
|
2 | import Test.DocTest (doctest)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^