Fundeps question

Martin Sulzmann sulzmann@comp.nus.edu.sg
Fri, 7 Mar 2003 11:42:49 +0800 (GMT-8)


There seems to be a mismatch between hugs and ghc.

hugs -98
:version
-- Hugs Version February 2001 

accepts the following:

====== EqList.hs ========

module EqList where

data Nil = Nil
data Cons x xs = Cons x xs

class EqList a b c | a b -> c where
     comp :: a -> b -> c
     comp _ _ = error "" 

class SameType a b | a -> b, b -> a 

instance SameType a a
instance EqList Nil Nil Nil
instance (SameType t1 t2, EqList l1 l2 r) => 
          EqList (Cons t1 l1) (Cons t2 l2) r


e x y = comp (Cons x Nil) (Cons y Nil)
-- :t e yields e :: a -> a -> Nil 


--f = comp (Cons True Nil) (Cons 'a' Nil)
-- yields
{-
 Constraints are not consistent with functional dependency
*** Constraint       : SameType Bool Char
*** And constraint   : SameType Char Char
*** For class        : SameType a b
*** Break dependency : b -> a
-}

=================

My guess is that ghc doesn't like if you "inherit" dependencies.
Here's a simplified example:

===========
class Force a b | a -> b, b -> a

instance Force a a

class Test a b

instance Force a b => Test a b
===========

Again ghc complains whereas hugs accepts the above code.

Martin