升级到Ubuntu13.10之后,我的Haskell代码之一无法编译。以下代码在(至少) ghc-7.0.x下编译没有问题,但在ghc-7.6.2 (使用无序容器-0.2.2.1)下失败:
{-# LANGUAGE OverloadedStrings, DeriveDataTypeable #-}
import Data.Typeable
import Data.Data
import qualified Data.HashMap.Strict as HM
data Bar = Bar { bar :: String } deriving(Data, Typeable)
data Foo = Foo { foo :: HM.HashMap String Bar } deriving(Data, Typeable)我得到的错误是:
deriving-hm-fail.hs:7:58:
No instance for (Data (HM.HashMap String Bar))
arising from the 'deriving' clause of a data type declaration
Possible fix:
add an instance declaration for (Data (HM.HashMap String Bar))
or use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
When deriving the instance for (Data Foo)Data.HashMap.Strict具有实例声明:(数据k,数据v,Eq k,Hashable k) =>数据(HashMap K v)。因为Bar是数据的一个实例,这应该有效,还是我遗漏了什么?
发布于 2013-09-28 09:11:27
做了一些实验后,我发现随Ubuntu13.04提供的无序容器-0.2.2.1与ghc-7.6.2不兼容(也是由Ubuntu提供的)。当我安装最新的无序容器时,它可以工作(但后来它与其他软件包发生冲突)。
看来,由Ubuntu提供的Haskell环境很糟糕。清除所有libghc-*包,并重新安装从Hackage代替,修复一切。
发布于 2013-09-27 16:28:15
它不仅应该工作,而且在Linux上也适用于GHC 7.6.3x86-64。也许这是一个7.6.2的bug?我会去找找变化的人。
https://stackoverflow.com/questions/19055669
复制相似问题