我正在使用cabal帮助组织我的依赖项,构建进程,并测试我正在进行的一个小型Haskell项目.当前的cabal文件包含如下行:
library
hs-source-dirs: src
exposed-modules: Project.Exposed1
, Project.Exposed2
-- pretty please don't use below modules
, TestingUtilityFunctions
, GenericUtilityFunctions
other-modules: Convenient submodule for responsibility separation
, Another one
executable E1
-- relies on Project for both Project.Exposed1 AND GenericUtilityFunctions
testsuite T2
-- relies on Project for both Project.Exposed2 AND TestingUtilityFunctions
Run Code Online (Sandbox Code Playgroud)
我需要保持TestingUtilityFunctions和GenericUtilityFunctions暴露,因为它们出现在E1和T2.但是,它们不应该出现在库中,因为库的功能不是提供通用的实用程序功能(我根据需要改变),而是提供Project.Exposed*模块公开的接口.
有没有办法建立一个"私有"库(或几个,以最大限度地减少依赖性过度包含),我可以在我的包中使用,但跨越可执行文件和测试套件?
dfe*_*uer 10
其中一种方法containers是使用CPP有条件地暴露某些绑定,具体取决于是否正在运行测试版本.
在大多数情况下,正确的方法是暴露你的内部模块,其名称类似于Blah.Blah.Internal,让你的用户在背后玩游戏,同时庄严地(但含蓄地)警告他们他们最好小心,他们不能依赖从版本到版本保持相同的任何东西.