haskell - 什么是 Cabal 组件以及如何使用它们?

标签 haskell cabal cabal-install

cabal build --help 和其他人在类似的句子中提到组件

Build one or more targets from within the project. The available targets are   
the packages in the project as well as individual components within those
packages, including libraries, executables, test-suites or benchmarks. Targets
can be specified by name or location. If no target is specified then the
default is to build the package in the current directory.

来自cabal user guide9 中也提到了它们。 Setup.hs 命令,以及 给出两个前缀 exe:lib: 来选择它们。还有更多这些前缀吗?

最佳答案

组件是节后面的任何东西,具有自己的一组依赖项等。因此它可以是多个子库、多个可执行文件、测试套件等。

你是对的,这是没有充分记录的!在源代码中我们可以看到以下内容( https://github.com/haskell/cabal/blob/00a2351789a460700a2567eb5ecc42cca0af913f/Cabal/src/Distribution/Simple/BuildTarget.hs#L569 )

matchComponentKind :: String -> Match ComponentKind
matchComponentKind s
  | s `elem` ["lib", "library"]                 = return' LibKind
  | s `elem` ["flib", "foreign-lib", "foreign-library"] = return' FLibKind
  | s `elem` ["exe", "executable"]              = return' ExeKind
  | s `elem` ["tst", "test", "test-suite"]      = return' TestKind
  | s `elem` ["bench", "benchmark"]             = return' BenchKind
  | otherwise = matchErrorExpected "component kind" s
  where
    return' ck = increaseConfidence >> return ck

这就是完整列表!

关于haskell - 什么是 Cabal 组件以及如何使用它们?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62994278/

相关文章:

algorithm - 在广度优先搜索中避免重复

haskell - Cabal 源包和 haddock 文档

haskell - 哪个 Haskell 包包含给定模块

haskell - 使用 cabal 时插件包未知符号

html - 无法从某些网站读取 html

haskell - dataToTag 参数的严格性

haskell - 在数据类型构造函数中使用类

haskell - 如何使用 Cabal 生成 Haddock 文档?

haskell - 使用 cabal 分析可执行文件

haskell - 为什么 HsColour 二进制文件的存在/不存在会强制重新编译 QuickCheck 库?