In our attempts to do more complicated things we came up with the following example:

module Strange where

class Apply a b c
| a -> b c where
apply :: a -> b -> c

instance Apply (a -> b) a b where
apply f a = f a

instance Apply d e f => Apply (a -> b , d) (a, e) (b, f) where
apply ~(a2b, d) ~(a, e) = (a2b a, apply d e)

what _ = apply ( incv, incv ) ((v= 5) , (v= 5))

incv (v = i) = (v = i+1)
For this we get the following error message:

ERROR "Strange.hs" (line 12): Ambiguous type signature in inferred type
*** ambiguous type : (Apply (Rec (v :: a) -> Rec (v :: a),Rec (v :: b) -> Rec (v :: b)) (Rec (v :: a),Rec (v :: c)) (Rec (v :: a),
), Num a, Num c, Num b) => e -> (Rec (v :: a),)
*** assigned to : what

Can someone explain what makes the difference between the first and the second component of the cartesian products we are using? It seems that the dependencies we have given work only at the outer level, but are not being used in disambiguating the contexts given in the instance declarations.

Is this a bug in Hugs or in our understanding?

Doaitse Swierstra and Pablo Azero



__________________________________________________________________________
S. Doaitse Swierstra, Department of Computer Science, Utrecht University
(Prof. Dr) P.O.Box 80.089, 3508 TB UTRECHT, the Netherlands
Mail: mailto:[EMAIL PROTECTED]
WWW: http://www.cs.uu.nl/
PGP Public Key: http://www.cs.uu.nl/people/doaitse/
tel: +31 (30) 253 3962, fax: +31 (30) 2513791
__________________________________________________________________________

Reply via email to