1 {-# OPTIONS -fglasgow-exts #-}
3 -- !!! Functional dependency test. Hugs [Apr 2001] fails to typecheck this
4 -- We should infer this type for foo
5 -- foo :: Q (S (S Z)) (S Z)
7 module ShouldCompile where
12 class Add a b c | a b -> c where add :: a -> b -> c
15 instance Add a b c => Add (S a) b (S c)
17 class Mul a b c | a b -> c where mul :: a -> b -> c
20 instance (Mul a b c, Add b c d) => Mul (S a) b d
24 -- Problem here. This is the addition of rational
25 -- numbers: (a/b) + (c/d) = (ad+bc)/bd
30 Add ad bc ad_bc) => Add (Q a b) (Q c d) (Q ad_bc bd)
36 foo = add (Q sz sz) (Q sz sz)