首页 > 解决方案 > haskell 堆栈不会安装日期

问题描述

在一个独立的模块中,我使用通过 cabal 安装的日期包http://hackage.haskell.org/package/dates ,它工作正常。但是当我尝试使用堆栈从这个模块中制作一个小包时出现了一个问题。日期包在依赖项中适当列出,但它不起作用。当我尝试在项目沙箱中使用堆栈手动安装包时,出现以下错误。同时,我可以在堆栈沙箱外使用 cabal 安装此软件包而不会出现问题。

沙盒中的版本:ghc-8.4.3 stack-1.7.1

系统版本:ghc-8.0.2 cabal-1.24.0.2(编译 1.24.2.0)

错误信息:

Configuring dates-0.2.2.1...
Preprocessing library for dates-0.2.2.1..
Building library for dates-0.2.2.1..
[1 of 4] Compiling Data.Dates.Internal ( Data/Dates/Internal.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/Data/Dates/Internal.o )
[2 of 4] Compiling Data.Dates.Types ( Data/Dates/Types.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/Data/Dates/Types.o )

/tmp/stack16211/dates-0.2.2.1/Data/Dates/Types.hs:62:10: error:
    • No instance for (Semigroup DateTime)
        arising from the superclasses of an instance declaration
    • In the instance declaration for ‘Monoid DateTime’
   |
62 | instance Monoid DateTime where
   |          ^^^^^^^^^^^^^^^

标签: haskellhaskell-stack

解决方案


最后,我需要将 stack.yaml 文件中的解析器更改为旧版本(lts-8.24),这将强制使用 ghc-8.0.2。使用

堆栈 --resolver ghc-8.0.2 设置/构建

当我这样做时,并没有阻止堆栈使用最新的 ghc 版本

堆栈执行 blah-exe

这引发了冲突。


推荐阅读