[Haskell-cafe] Accepted by Hugs, not by GHC

Hans van Thiel hthiel.char at zonnet.nl
Sat May 19 10:30:56 EDT 2007


Hello All,

Defining a partially ordered set as:

data Porder = HI | LW | NT deriving (Eq)

class (Eq a) => Poset a where
    pcompare :: a -> a -> Porder

and defining an instance for type synonym RuRe: 

type RuRe = ([Int],[Int])

instance Poset RuRe where
     pcompare (x1,y1) (x2,y2)
              | isSub x2 x1 = HI
              | isSub x1 x2 = LW
              | otherwise = NT

causes no problems in Hugs (-98 flag) but compiling with GHC produces:

[hvt at localhost Sandbox]$ ghc --make Main.hs -O 

[5 of 6] Compiling Abduce           ( Abduce.hs, Abduce.o )

Abduce.hs:110:0:
    Illegal instance declaration for `Poset RuRe'
        (The instance type must be of form (T a b c)
         where T is not a synonym, and a,b,c are distinct type
variables)
    In the instance declaration for `Poset RuRe'

I've tried several changes, like not using the type synonym, but can't
get it right. (I'm using the ghc 6.6.1 Fedora Core 6 package). 

Many thanks in advance!

Hans van Thiel




More information about the Haskell-Cafe mailing list