Cabal:用源代码构建dir

0xA*_*xAX 18 haskell cabal

我有一个src目录.在这个目录中我有Main.hs文件和Test目录.在Test我有Test.hs模块的目录中.我需要用cabal编译它.

在我的cabal文件中,我有:

Executable main
  -- .hs or .lhs file containing the Main module.
      Main-is: src/Main.hs  
Run Code Online (Sandbox Code Playgroud)

  -- Modules not exported by this package.
     Other-modules: Test.Test
Run Code Online (Sandbox Code Playgroud)

当我这样做cabal configure没关系,但当我尝试时,cabal build我得到以下错误:

cabal build
Preprocessing executables for main-0.0.1...
cabal: can't find source for Test/Test in ., dist/build/autogen
Run Code Online (Sandbox Code Playgroud)

如何正确构建文件Main.hs和其他目录.hs

谢谢.

ehi*_*ird 22

如果Test.Test已定义src/Test/Test.hs,则需要

hs-source-dirs: src
Run Code Online (Sandbox Code Playgroud)

在您的Cabal文件的可执行部分中.请注意,您的main-is文件路径应该相对于源目录,因此在这种情况下,您应该将其更改为Main.hs.