Haskell Stack基础使用失败

3

我正在学习Haskell,并尝试设置我的Emacs开发环境(参考这里)。
其中一件事情是安装hindent
推荐的方法在这里只需要运行stack install hindent。我猜应该安装在stack的global-project空间中。我全局的stack yaml文件位于$HOME/.stack/global-project/stack.yaml

flags: {}
extra-package-dbs: []
packages: []
extra-deps: []
resolver: ghc-7.10.3

我没有使用任何系统 ghc(我的 $PATH 上没有 ghcghci)。
在执行 stack install hindent 时,它建议我扩展 extra-deps

Run from outside a project, using implicit global project config
Using resolver: ghc-7.10.3 from implicit global project's config file: /home/me/.stack/global-project/stack.yaml

While constructing the build plan, the following exceptions were encountered:

In the dependencies for hindent-5.2.1:
    descriptive must match >=0.7 && <0.10, but the stack configuration has no specified version
                (latest applicable is 0.9.4)
    exceptions must match -any, but the stack configuration has no specified version (latest applicable is 0.8.3)
    haskell-src-exts must match >=1.18, but the stack configuration has no specified version
                     (latest applicable is 1.18.2)
    monad-loops must match -any, but the stack configuration has no specified version (latest applicable is 0.4.3)
    mtl must match -any, but the stack configuration has no specified version (latest applicable is 2.2.1)
    path must match -any, but the stack configuration has no specified version (latest applicable is 0.5.9)
    path-io must match -any, but the stack configuration has no specified version (latest applicable is 1.2.0)
    text must match -any, but the stack configuration has no specified version (latest applicable is 1.2.2.1)
    unix-compat must match -any, but the stack configuration has no specified version (latest applicable is 0.4.2.0)
    utf8-string must match -any, but the stack configuration has no specified version (latest applicable is 1.0.1.1)
    yaml must match -any, but the stack configuration has no specified version (latest applicable is 0.8.20)

Recommended action: try adding the following to your extra-deps in /home/me/.stack/global-project/stack.yaml:
- descriptive-0.9.4
- exceptions-0.8.3
- haskell-src-exts-1.18.2
- monad-loops-0.4.3
- mtl-2.2.1
- path-0.5.9
- path-io-1.2.0
- text-1.2.2.1
- unix-compat-0.4.2.0
- utf8-string-1.0.1.1
- yaml-0.8.20

当我执行所提出的操作时,它会建议一些新的依赖项(这些可能是先前添加的依赖项的依赖项等等)。最终导致两个依赖项存在不满足版本的情况。我认为我的配置有问题(或者对栈的理解有误),因为我认为获取隐式依赖关系是构建工具的工作。是否有更有经验的人可以推断出我的初学者错误?

2
你的全局项目中的解析器为何是 ghc-7.10.3?(我认为这可能是你遇到问题的原因。) - duplode
2个回答

4

一般不建议使用ghc版本作为解析器,因为你已经发现的原因:你需要手动指定许多包版本。相反,我建议切换到lts-6.23或类似的版本。


谢谢。这很有道理,但与我迄今所见的其他生态系统中的标准构建工具有些不同。通过lts-6.23甚至lts-7.5安装的hindent版本是<5,但我需要5>。我已经切换到夜间版以获得我需要的内容。根据堆栈哲学,我的理由是否正确,或者我应该在某个地方指定单个软件包(hindent)的特定版本? - foki
1
你可以尝试在命令行上指定hindent的版本,但选择一个带有所需版本的夜间快照是个不错的选择。 - Michael Snoyman

0

不确定。如果你只是想快速入门:

stack upgrade --git  && \
rm -rf ~/.stack      && \
stack setup          && \
stack install hindent

为什么不使用 GHC 8.X 和全新的 Stack 呢? ;)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接