我正在尝试 运行 cabal 构建,但出现以下错误

I am trying to run cabal build, and I get the following error

Build profile: -w ghc-9.0.1 -O1
In order, the following will be built (use -v for more details):
 - csound-expression-dynamic-0.3.8 (lib) (requires build)
 - csound-expression-typed-0.2.7 (lib) (requires build)
 - csound-expression-opcodes-0.0.5.1 (lib) (requires build)
 - csound-expression-5.3.4 (lib) (requires build)
 - csound-sampler-0.0.10.0 (lib) (requires build)
 - csound-catalog-0.7.4 (lib) (requires build)
 - solve-0.2.0.0 (exe:solve) (first run)
Starting     csound-expression-dynamic-0.3.8 (lib)
Building     csound-expression-dynamic-0.3.8 (lib)

Failed to build csound-expression-dynamic-0.3.8.
Build log (
C:\Users\Shiro\AppData\Roaming\cabal\logs\ghc-9.0.1\csound-expres_-0.3.8-3e9f98bb37e846ae1dd789bc6c80c4d50504a214.log
):
Preprocessing library for csound-expression-dynamic-0.3.8..
Building library for csound-expression-dynamic-0.3.8..
[ 1 of 15] Compiling Csound.Dynamic.Tfm.DeduceTypes ( src\Csound\Dynamic\Tfm\DeduceTypes.hs, dist\build\Csound\Dynamic\Tfm\DeduceTypes.o )
[ 2 of 15] Compiling Csound.Dynamic.Tfm.UnfoldMultiOuts ( src\Csound\Dynamic\Tfm\UnfoldMultiOuts.hs, dist\build\Csound\Dynamic\Tfm\UnfoldMultiOuts.o )
[ 3 of 15] Compiling Csound.Dynamic.Types.Exp ( src\Csound\Dynamic\Types\Exp.hs, dist\build\Csound\Dynamic\Types\Exp.o )

src\Csound\Dynamic\Types\Exp.hs:202:66: error:
    * No instance for (Data.Functor.Classes.Eq1 RatedExp)
        arising from a use of `=='
    * In the second argument of `(&&)', namely
        `(ratedExpExp re == EmptyExp)'
      In the expression:
        isNothing (ratedExpDepends re) && (ratedExpExp re == EmptyExp)
      In an equation for `isEmptyExp':
          isEmptyExp e
            = isNothing (ratedExpDepends re) && (ratedExpExp re == EmptyExp)
            where
                re = unFix e
    |
202 | isEmptyExp e = isNothing (ratedExpDepends re) && (ratedExpExp re == EmptyExp)
    |                                                                  ^^
cabal.exe: Failed to build csound-expression-dynamic-0.3.8 (which is required
by exe:solve from solve-0.2.0.0). See the build log above for details.

这是我第一次接触 Haskell 和 Cabal。因此,据我了解,我需要 solve.exe,它需要 csound-expression-dynamic-0.3.8,它需要其他东西。我如何让它工作?

似乎 csound-expression-dynamic 还不兼容 GHC 9.0.1。试试GHC 8.10.7吧,还是推荐的通用版本。

我已经在他们的 GitHub 页面上提出了一个关于此的问题:https://github.com/spell-music/csound-expression-dynamic/issues/2

问题是 ratedExpExp re == EmptyExp 在文件中比 $(deriveEq1 ''RatedExp) 早。 GHC 9.0.1's release notes 这样说:

  • Breaking change: Template Haskell splices now act as separation points between constraint solving passes. It is no longer possible to use an instance of a class before a splice and define that instance after a splice. For example, this code now reports a missing instance for C Bool:

    class C a where foo :: a
    bar :: Bool
    bar = foo
    $(return [])
    instance C Bool where foo = True
    

这可以通过将 isEmptyExp 方法移动到 $(deriveEq1 ''RatedExp) 拼接之后来解决。一旦这样做,您将 运行 陷入另一个关于重复实例的错误。这可以通过将 instance Hashable1 IM.IntMap 包装在 #if !MIN_VERSION_hashable(1,3,4) 中来解决,之后它将在 GHC 9.0.1 上正常编译。我打开 https://github.com/spell-music/csound-expression-dynamic/pull/3 以在上游进行这些更改,但在它们被接受之前,您可以手动进行它们以构建它。

更新: 我修复此问题的 PR 已合并,新版本已上传到 Hackage。完成 cabal update 后,基于 GHC 9 的构建现在应该会成功,无需对您的项目进行任何更改。