The stack setup will download the compiler if necessary in an isolated location (default ~/.stack) that won't interfere with any system-level installations. (For information on installation paths, please use the stack path command.).
~ stack install ghc-mod
Error: While constructing the build plan, the following exceptions were
encountered:
In the dependencies for ghc-mod-5.8.0.0:
Cabal-2.0.1.1 from stack configuration does not match >=1.18 && <1.25
(latest matching version is 1.24.2.0)
base-4.10.1.0 from stack configuration does not match >=4.6.0.1 && <4.10
(latest matching version is 4.9.1.0)
cabal-helper must match <0.8 && >=0.7.3.0, but the stack configuration has
no specified version (latest matching version is 0.7.3.0)
extra-1.6.2 from stack configuration does not match <1.6 && >=1.4 (latest
matching version is 1.5.3)
ghc-8.2.2 from stack configuration does not match >=7.6 && <8.2
monad-journal-0.8.1 from stack configuration does not match <0.8 && >=0.4
(latest matching version is 0.7.2)
optparse-applicative-0.14.0.0 from stack configuration does not
match >=0.13.0.0 && <0.14 (latest matching
version is 0.13.2.0)
needed since ghc-mod is a build target.
Some potential ways to resolve this:
* Recommended action: try adding the following to your extra-deps
in /home/user/.stack/global-project/stack.yaml:
- Cabal-1.24.2.0
- base-4.9.1.0
- cabal-helper-0.7.3.0
- extra-1.5.3
- monad-journal-0.7.2
- optparse-applicative-0.13.2.0
* Set 'allow-newer: true' to ignore all version constraints and build anyway.
* You may also want to try using the 'stack solver' command.
Plan construction failed.
安装 Haskell Tool Stack
这样就可以开始用 stack 来构建项目:
更换 stack 镜像源为清华镜像
安装 VSCode 相关插件
语法高亮
Haskell Syntax Highlighting
Linting 插件
haskell-linter
安装完之后会提示错误:
因为我们还没有安装
hlint
:然后在 VSCode 中配置
hlint
路径:Haskell ghc-mod
Haskell ghc-mod
同样需要安装
ghc-mod
:这里可能会报错:
原因在于 ghc-mod 不支持当前的 GHC 版本,所以需要降级 GHC 然后再安装。
在
~/.stack/global-project/stack.yaml
中修改字段:之后同样需要在 VSCode 中修改路径,方法如上,不再赘述。