使用堆栈安装 hackage 包(不是在 LTS 或 nightly 中)

installing hackage package with stack (not in LTS or nightly)

我刚开始使用堆栈,但我不完全确定如何引入出现在 hackage 中但不出现在策划构建中的包。

特别想拉进来thrift-0.10.0。似乎我无法在我的 project.cabal 文件中指定它,extra-deps 部分也不起作用,因为没有包含此包的解析器。

当我 运行 stack install thrift-0.10.0 时,我收到以下错误:

While constructing the build plan, the following exceptions were encountered:
In the dependencies for thrift-0.10.0:
    vector-0.11.0.0 must match ==0.10.12.2 (latest applicable is 0.10.12.2)

我不太确定 (a) stack install 做了什么,以及 (b) 如何解决构建计划,因为 thrift 包在 vector-0.10.12.2 上指定了一个等式 (==)包裹。如果我尝试在我的 package.cabal 中包含相关的 vector == 0.10.12.2,那也会失败。我需要指定更早的解析器吗?

我意识到关于这个构建工具我还有很多东西要学习,但在这种情况下,我的主要问题似乎没有现成的文档是:

how do I include a hackage package in my stack build?

nor does the extra-deps section work since there is no resolver that contains this package.

extra-deps 可以包含任何黑客包。

(a) what stack install does

它只是构建包 + 将可执行文件复制到 .local/bin

安装不应用于依赖项,而应用于本地项目/来自 hackage 的应用程序(带有可执行文件的程序包)。安装项目的依赖项没有任何好处,而是应该在 stack.yaml

中指定它们

(b) how to resolve the build plan since the thrift package specifies an equality (==) on the vector-0.10.12.2 package.

thrift 包有这样的 (==) 约束似乎真的很难看。要解决它,请在 stack.yaml 中执行 "allow-newer: true" (导致约束被忽略)。或者,可能更好,将 `vector-0.10.12.2" 添加到您的 extra-deps。

for which no documentation seems readily available is:

how do I include a hackage package in my stack build?

查看文档的这一部分:https://docs.haskellstack.org/en/stable/GUIDE/#external-dependencies