为什么用 stack nightly 构建时 GHC 版本不如预期?

Why is the GHC version not as expected when building with stack nightly?

使用堆栈时如何确定 GHC 版本?

我认为这将是解析器,但是...

我有以下堆栈文件:

resolver: nightly-2018-07-10
packages:
- .

这是 Stackage 上的内容:

Stackage Nightly 2018-07-10 (ghc-8.4.3)
Published on 2018-07-10
View changes
stack resolver: nightly-2018-07-10 

然后我构建:

$ stack clean
$ stack build
Building all executables for `PyrethrumPre' once. After a successful build      
of all of them, only specified executables will be rebuilt.
PyrethrumPre-0.1.0.0: configure (exe)
Configuring PyrethrumPre-0.1.0.0...
PyrethrumPre-0.1.0.0: build (exe)
Preprocessing executable 'PyrethrumPre' for PyrethrumPre-0.1.0.0..
Building executable 'PyrethrumPre' for PyrethrumPre-0.1.0.0..
[1 of 2] Compiling MTLPlusLens      ( src\MTLPlusLens.hs, .stack-work\dist  d103d30\build\PyrethrumPre\PyrethrumPre-tmp\MTLPlusLens.o )
[2 of 2] Compiling Main             ( src\Main.hs, .stack-work\distd103d30\build\PyrethrumPre\PyrethrumPre-tmp\Main.o )
Linking .stack-work\distd103d30\build\PyrethrumPre\PyrethrumPre.exe ...
PyrethrumPre-0.1.0.0: copy/register
Installing executable PyrethrumPre in C:\PyrethrumPre\.stack-work\install\cd327184\bin

在这一点上,根据解析器,我预计 GHC 为 8.4.3:

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.2.2

为什么GHC版本不符合预期?

谢谢

Stack 在 ~/.stack 下的 "private" 位置安装您的项目所需的 GHC 版本,这不会是您常规 $PATH 中的 ghc。您看到的 ghc 版本是系统范围内安装的版本(可能由系统的包管理器安装),Stack 默认会忽略它。要查看 Stack 实际用于构建项目的版本,请使用 stack exec -- ghc --versionstack exec 创建一个 shell 上下文,其中包含 $PATH 上 ghc 的正确版本,以及其他更改。