haskell - Cabal 无法安装日期和半组
问题描述
如果我执行$ cabal install semigroup
,我会收到错误
Data/Semigroup.hs:29:22: error:
Ambiguous occurrence ‘Semigroup’
It could refer to either ‘Prelude.Semigroup’,
imported from ‘Prelude’ at Data/Semigroup.hs:2:8-21
(and originally defined in ‘GHC.Base’)
or ‘Data.Semigroup.Semigroup’,
defined at Data/Semigroup.hs:22:1
|
29 | instance Monoid a => Semigroup (Identity a) where
| ^^^^^^^^^
(在其他几次出现时重复)
同样,如果我$ cabal install dates
,
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
| ^^^^^^^^^^^^^^^
cabal: Leaving directory '/tmp/cabal-tmp-16926/dates-0.2.2.1'
cabal: Error: some packages failed to install:
dates-0.2.2.1-ILbYRzHuQkwCfqySpiVks0 failed during the building phase. The
exception was:
ExitFailure 1
这是一个错误吗?以及如何解决它?
解决方案
Semigroup 类现在是 GHC 8.4.x 中基础的一部分:
class Semigroup a where
(<>) :: a -> a -> a
GHC.Base.sconcat :: GHC.Base.NonEmpty a -> a
GHC.Base.stimes :: Integral b => b -> a -> a
{-# MINIMAL (<>) #-}
-- Defined in ‘GHC.Base’
但在旧版本的 GHC 中,它不是基础的一部分,最初存在于semigroups
包中。semigroups
比您尝试安装的版本还要旧semigroup
,并且与现在的部分存在类似的冲突base
(感谢@Li-yao 的评论)。因此,semigroup 包不应与较新的 ghc/base 一起使用。
您的第二个问题是dates
新基础的版本没有更新,这要求所有 Monoid 实例也是 Semigroup 的实例:
class Semigroup a => Monoid a where
mempty :: a
mappend :: a -> a -> a
mconcat :: [a] -> a
{-# MINIMAL mempty #-}
-- Defined in ‘GHC.Base’
您可以对dates
软件包提出问题。
推荐阅读
- c - 如何找到对象文件之间的依赖关系?
- sql - Visual Studio 中的 Azure SQL 数据库 - 目标平台差异(V12 与普通)?
- c# - 获取用户指定的系统短时间格式(不是系统文化)
- networkx - 使用networkx在折线图中找到与顶点对应的图边
- java - 如何将单词存储到数组/数组列表中而没有重复的单词
- c# - 虚拟 C# 成员可以内联吗?
- apache-spark - DataProc Cluster Spark Job 提交启动 NodeManager 失败
- python-3.x - 为什么 numpy.array() 创建一个没有正确形状的数组?
- asp.net - 获取用于当前请求的 IIS 绑定
- java - java.sql.SQLIntegrityConstraintViolationException 春季启动