
Hi Matti,
This example relies on generic instance deriving, which was only added
in hashable 1.2.0.0, so you need that version or later. For older
versions, you'll have to write your own Hashable instance
implementation.
Regards,
Erik
On Mon, Jun 15, 2015 at 10:05 AM, Matti Nykänen
Hello,
A practical question about getting hashing to work.
Having used Data.Map before, I wanted to try Data.HashMap.Lazy instead: ---- {-# LANGUAGE DeriveGeneric #-}
import Data.HashMap.Lazy as HM
import GHC.Generics (Generic) import Data.Hashable
data Colour = Red | Green | Blue deriving Generic
instance Hashable Colour
foo = HM.insert Red ---- The data and its instance definition are directly from the web page https://hackage.haskell.org/package/hashable-1.2.1.0/docs/Data-Hashable.html.
However, I det the following error: ---- GHCi, version 7.6.3: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. [1 of 1] Compiling Main ( htest.hs, interpreted )
htest.hs:13:8: No instance for (hashable-1.1.2.5:Data.Hashable.Hashable Colour) arising from a use of `insert' Possible fix: add an instance declaration for (hashable-1.1.2.5:Data.Hashable.Hashable Colour) In the expression: insert Red In an equation for `foo': foo = insert Red Failed, modules loaded: none. ---- I do not know what is wrong or how I could fix it.
Note that my Haskell had originally the older hashable-1.0.0 package, but I cabal-installed this hashable-1.1.2.5 because surfing the net suggested that it would be much better. Could it be the case that the instance goes somehow in the wrong class? -- Matti Nykänen _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe