Skip to content

generic classes broken

I failed to get generic classes working with snapshot ghc-6.8.0.20070920-i386-unknown-linux.tar.bz2.

I tried the following module:


module Gen where

import Data.Generics

class Equal a where
      equal :: a -> a -> Bool
      equal {| Unit |}    Unit        Unit        = True
      equal {| u :+: v |} (Inl x)     (Inl y)     = equal x y
      equal {| u :+: v |} (Inr x)     (Inr y)     = equal x y
      equal {| u :+: v |} _           _           = False
      equal {| u :*: v |} (x1 :*: x2) (y1 :*: y2) = equal x1 y1 && equal x2 y2

instance Equal Bool

and got


klee@romulus:~/tmp> ghci -fglasgow-exts -XGenerics
GHCi, version 6.8.0.20070920: http://www.haskell.org/ghc/  :? for help
Loading package base ... linking ... done.
Prelude> :l Gen.hs
[1 of 1] Compiling Gen              ( Gen.hs, interpreted )

Gen.hs:13:0:
      Can't find interface-file declaration for variable GHC.Base.$gfromBool
        Probable cause: bug in .hi-boot file, or inconsistent .hi file
        Use -ddump-if-trace to get an idea of which file caused the error
      In the first argument of `a', namely `(GHC.Base.$gfromBool b)'
      In the first argument of `(\ a -> a)', namely
          `(a (GHC.Base.$gfromBool b))'
      In the expression: (\ a -> a) (a (GHC.Base.$gfromBool b))
Failed, modules loaded: none.

Edited by Ian Lynagh -
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information