Cabal: build dir with source

社会主义新天地 提交于 2019-12-08 14:39:40

问题


I have a src directory. In this directory I have Main.hs file and Test directory. In the Test directory I have Test.hs module. I need to compile it with cabal.

In my cabal file I have:

Executable main
  -- .hs or .lhs file containing the Main module.
      Main-is: src/Main.hs  

and

  -- Modules not exported by this package.
     Other-modules: Test.Test

When I do cabal configure it's OK, but when I try to cabal build I get the following error:

cabal build
Preprocessing executables for main-0.0.1...
cabal: can't find source for Test/Test in ., dist/build/autogen

How can I correctly build Main.hs and some other directories with .hs files?

Thank you.


回答1:


If Test.Test is defined in src/Test/Test.hs, you need

hs-source-dirs: src

in the Executable section of your Cabal file. Note that your main-is file path should be relative to the source directory, so in this case, you should change it to Main.hs.



来源:https://stackoverflow.com/questions/8543039/cabal-build-dir-with-source

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!