cabal build --ghc-option=-ddump-minimal-imports 不会为 main 生成导入文件

cabal build --ghc-option=-ddump-minimal-imports does not produce import files for main

ddump-minimal-imports 是一个很有价值的工具。我无法使其适用于我的 cabal 文件中的可执行文件和测试套件。

在我的 cabal 文件中我有:

test-suite testDatas6forTestDataItem
    type:       exitcode-stdio-1.0
    main-is:    Datas6TestDataItemTest.hs
    build-depends:
       base -any,
       time,
       monads-tf, 

    default-language: Haskell2010
    hs-source-dirs: ., srcexe
    ghc-options: -threaded  -ddump-minimal-imports

我在 dist 文件夹中找到了模块的导入文件,但没有找到测试和主文件的导入文件。 这是

感谢您的帮助!

我怀疑它们是被发射出来的,只是不在你预期的位置,所以我 运行 做了一个实验并证实了这一点。我分叉了 kazu 的 test example package 然后将额外的最小导入标志添加到 cabal 文件中,如下所示:

Test-Suite doctest
  Type:                 exitcode-stdio-1.0
  ...
  ghc-options: -threaded  -ddump-minimal-imports

Test-Suite spec
  Type:                 exitcode-stdio-1.0
  ...
  ghc-options: -threaded  -ddump-minimal-imports

文件 确实 显示在 dist/build/doctest/doctest-tmp/Main.importsdist/build/spec/spec-tmp/Main.imports 中的 dist 下。对于套件中还有其他文件的 spec,它们的导入也显示在同一目录中。