在 cabal 包中,为什么我应该有几乎相同的 `other-modules` 字段
In a cabal package why should I have almost identical `other-modules` fields
在我的 cabal 中,我有一个 library
和几个 executable
字段。我可以理解为什么 cabal 想要了解 .cabal
清单中的所有各种文件,甚至那些不是 exposed-modules
的文件。我的可执行文件只使用我库的 exposed-modules
中的模块。为什么 cabal 抱怨缺少 other-modules
?
version: 0.0.0.1
name: my-pkg
synopsis: A package
description: Please see README.md
homepage: https://homepage.com
license: BSD3
license-file: LICENSE
author: Me
maintainer: example@example.com
copyright: MIT
category:
build-type: Simple
cabal-version: >=1.10
library
hs-source-dirs: src
default-language: Haskell2010
ghc-options: -Wall -g -Wno-simplifiable-class-constraints -O2
exposed-modules: MyLib.Exposed.ImportedByExec
other-modules: MyLib.NotExposed.ExecShouldntCare
executable tool
hs-source-dirs: tools/Tool
default-language: Haskell2010
ghc-options: -Wall -g -Wsimplifiable-class-constraints
main-is: Main.hs
build-depends: base >= 4.7 && < 5
, my-pkg >= 0.1.0.1
other-modules: <why should anything be here to avoid a warning??>
编辑:也许这个问题等同于 "why does my-pkg not show up in stack exec -- ghc-pkg list
after I stack build
or even stack install
?"
在不知道 tools/Tools
目录的全部内容的情况下,我们只能推测您出现该错误的原因,但我的猜测是该目录中还有其他 haskell 文件。
other-modules
表示 files/modules 在您的项目中使用但未公开公开。他们是私有的 files/modules。来自 cabal 页面的详细信息:cabal - quickstart - 3.1.3. Modules included in the package.
还有一个工具叫做hpack which automates the creation of a cabal
file from an hpack
yaml
file and it can automatically populate the other-modules
field for you. You can also use it via stack。
在我的 cabal 中,我有一个 library
和几个 executable
字段。我可以理解为什么 cabal 想要了解 .cabal
清单中的所有各种文件,甚至那些不是 exposed-modules
的文件。我的可执行文件只使用我库的 exposed-modules
中的模块。为什么 cabal 抱怨缺少 other-modules
?
version: 0.0.0.1
name: my-pkg
synopsis: A package
description: Please see README.md
homepage: https://homepage.com
license: BSD3
license-file: LICENSE
author: Me
maintainer: example@example.com
copyright: MIT
category:
build-type: Simple
cabal-version: >=1.10
library
hs-source-dirs: src
default-language: Haskell2010
ghc-options: -Wall -g -Wno-simplifiable-class-constraints -O2
exposed-modules: MyLib.Exposed.ImportedByExec
other-modules: MyLib.NotExposed.ExecShouldntCare
executable tool
hs-source-dirs: tools/Tool
default-language: Haskell2010
ghc-options: -Wall -g -Wsimplifiable-class-constraints
main-is: Main.hs
build-depends: base >= 4.7 && < 5
, my-pkg >= 0.1.0.1
other-modules: <why should anything be here to avoid a warning??>
编辑:也许这个问题等同于 "why does my-pkg not show up in stack exec -- ghc-pkg list
after I stack build
or even stack install
?"
在不知道 tools/Tools
目录的全部内容的情况下,我们只能推测您出现该错误的原因,但我的猜测是该目录中还有其他 haskell 文件。
other-modules
表示 files/modules 在您的项目中使用但未公开公开。他们是私有的 files/modules。来自 cabal 页面的详细信息:cabal - quickstart - 3.1.3. Modules included in the package.
还有一个工具叫做hpack which automates the creation of a cabal
file from an hpack
yaml
file and it can automatically populate the other-modules
field for you. You can also use it via stack。