代码之家  ›  专栏  ›  技术社区  ›  Henricus V.

阴谋集团不能安装日期和半群

  •  0
  • Henricus V.  · 技术社区  · 8 年前

    如果我执行 $ 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
    

    这是虫子吗?如何解决这个问题?

    1 回复  |  直到 8 年前
        1
  •  0
  •   Thomas M. DuBuisson    8 年前

    半群类现在是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中,它不是base的一部分,最初生活在 semigroups 包裹。比 半群 是 semigroup 您正在尝试安装的,并且与现在的 base (感谢@李瑶的评论)。所以半群,这个包,不应该和新的ghc/base一起使用。

    你的第二个问题是 dates 不更新新基,它要求所有幺半群实例也是半群的实例:

    class Semigroup a => Monoid a where
      mempty :: a
      mappend :: a -> a -> a
      mconcat :: [a] -> a
      {-# MINIMAL mempty #-}
            -- Defined in ‘GHC.Base’
    

    你可以向 日期 包裹。

    推荐文章