Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Haskell 将内部模块暴露于阴谋集团的测试中_Haskell_Cabal - Fatal编程技术网

Haskell 将内部模块暴露于阴谋集团的测试中

Haskell 将内部模块暴露于阴谋集团的测试中,haskell,cabal,Haskell,Cabal,我参与了一个项目,它在一个类似这样的项目中定义了它的项目设置(省略了许多与此问题无关的属性): 但是在这里运行stack build会给我警告说,Data.Foo.Bar.Internal“应该添加到暴露的模块或./Foo.cabal中的其他模块”,然后在测试中出现生成错误,这似乎是由统一失败引起的(它指向库中定义的函数的函数参数,表示其类型必须是包Foo中定义的Data.Foo.Bar.Internal.Qux,并且类型Foo:Data.Foo.Bar.Internal.Qux不匹配) 如何向

我参与了一个项目,它在一个类似这样的项目中定义了它的项目设置(省略了许多与此问题无关的属性):

但是在这里运行
stack build
会给我警告说,
Data.Foo.Bar.Internal
“应该添加到暴露的模块或./Foo.cabal中的其他模块”,然后在测试中出现生成错误,这似乎是由统一失败引起的(它指向库中定义的函数的函数参数,表示其类型必须是包
Foo
中定义的
Data.Foo.Bar.Internal.Qux
,并且类型
Foo:Data.Foo.Bar.Internal.Qux
不匹配)


如何向测试套件公开内部模块,而不向库的使用者公开它们?

如评论中所述,不同的组件(内部库、可执行文件)应具有不同根下的模块

  • 这是一个反复出现的混淆点。例如:
  • 在阴谋集团的问题追踪器上有一个公开的问题,关于用适当的警告来澄清这一点;可靠地检测这种情况显然是非常重要的,因为它与合法的用例重叠:

如果您将
foo internal
.hs
文件移动到另一个
hs源目录
,例如,
src internal
,是否有帮助?@danidiaz可能;但我不确定我能做到这一点,因为这不是我的项目(这里的主要目的是让PR被接受)但我会在本地试用,看看是否有帮助。@danidiaz:是的,将文件移到其他根目录下似乎有效。我也遇到过同样的问题,但我在《Cabal用户指南》中没有找到确切的位置,即不同的库应该有不同的源文件夹。
library
  hs-source-dirs:    src
  build-depends:
                     base >= 4.9 && < 5,
                     some-other-deps
  exposed-modules:
                     Data.Foo.Bar,
                     Data.Foo.Baz
  other-modules:
                     Data.Foo.Bar.Internal

test-suite test
  hs-source-dirs:
                     tests
  build-depends:
                     foo-library
  other-modules:
                     Foo.Bar.Tests,
                     Foo.Baz.Tests
library foo-internal
  hs-source-dirs:    src
  build-depends:
                     base,
                     some-other-deps
  exposed-modules:
                     Data.Foo.Bar.Internal

library
  hs-source-dirs:    src
  build-depends:
                     base >= 4.9 && < 5,
                     foo-internal,
                     some-other-deps
  exposed-modules:
                     Data.Foo.Bar,
                     Data.Foo.Baz

test-suite test
  hs-source-dirs:
                     tests
  build-depends:
                     foo-library,
                     foo-internal
  other-modules:
                     Foo.Bar.Tests,
                     Foo.Baz.Tests