Question

After upgrading to Ubuntu 13.10, one of my Haskell codes fails to compile. The following code compiles without problems under (at least) ghc-7.0.x, but fails under ghc-7.6.2 (with unordered-containers-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)

The error I get is:

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 has the instance declaration: (Data k, Data v, Eq k, Hashable k) => Data (HashMap k v). Since Bar is an instance of Data, this should work, or am I missing something?

Was it helpful?

Solution 2

Having experimented a bit, I found that unordered-containers-0.2.2.1 shipped with Ubuntu 13.04 is incompatible with ghc-7.6.2 (also shipped by Ubuntu). When I install the latest unordered-containers from Hackage it works (but it conflicts later with other packages).

It seems that the Haskell environment shipped by Ubuntu is botched. Purging all libghc-* packages and reinstalling from Hackage instead, fixed everything.

OTHER TIPS

Not only should it work, it does work with GHC 7.6.3 x86-64 on Linux. Perhaps this is a 7.6.2 bug? I'd look in the changelog.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top