2013-09-27 73 views
3

升級到Ubuntu 13.10後,我的一個Haskell代碼無法編譯。下面的代碼編譯沒有下(至少)GHC-的7.0.x的問題,但在GHC-7.6.2失敗(與無序的容器-0.2.2.1):Haskell GHC-7.6.2派生數據和類型與哈希映射

{-# 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具有實例聲明:(Data k,Data v,Eq k,Hashable k)=> Data(HashMap kv)。既然Bar是數據的一個實例,這應該可行,或者我錯過了什麼?

回答

1

經過一番嘗試,我發現Ubuntu 13.04附帶的unordered-containers-0.2.2.1與ghc-7.6.2(也由Ubuntu發佈)不兼容。當我從Hackage安裝最新的無序容器時,它可以工作(但與其他軟件包稍後會發生衝突)。

看來Ubuntu發佈的Haskell環境已經過時了。清除所有libghc- *包並從Hackage重新安裝,修復所有問題。

4

它不僅應該工作,它確實在Linux上與GHC 7.6.3 x86-64一起工作。也許這是一個7.6.2的錯誤?我會看看更新日誌。