较旧的 Cabal 或 Haskell 项目能否在较新版本的 Cabal 和 Haskell 上 运行?

Can older Cabal or Haskell projects be run on newer versions of Cabal and Haskell?

我正在尝试构建我的项目,但我 运行 遇到了一个非常奇怪的问题。我让我的朋友用 Chocolatey 安装 Haskell,当他用 cabal buildcabal run project 编译我的项目时,他 运行 出现了以下错误,我只是没有有:

Expr.hs:103:1: error:
    Type applications in patterns are not yet supported
    |
103 | evalVal env val @(HInteger _)      = return $ val
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

我原以为 cabal 文件会处理依赖关系,但显然不会。粗略的搜索也证明是徒劳的,因为我什至找不到另一个有同样错误的人。

我不确定问题是由于他在 ghc 9.0.1cabal 3.4 而我在 ghc 8.8.3cabal 3.2 还是由于对于不同的操作系统,他是 Windows 而我是 OSX.

我担心的是,如果我升级我的 ghc 和 cabal 版本,那么我会 运行 进入这个错误,我将不得不重新安装第一次混乱和困难的所有东西

事实证明这是 GHC 9.0 中的更改:Whitespace-sensitive !, ~, @, and $

这是第二点:

f @ x = y

Before: value binding that binds both f and x to y using an as-pattern After: infix function named (@)

To restore the old behavior, remove the leading and trailing whitespace around @, like so:

f@x = x

所以如果你把它改成

evalVal env val@(HInteger _)      = return $ val

它应该适用于两种编译器