[mercury-users] functional dependencies question
Ian MacLarty
maclarty at cs.mu.OZ.AU
Tue Jan 17 02:52:30 AEDT 2006
Hello,
Why will a program with the following typeclass definitions not compile?
:- typeclass tc1(S, T) <= (S -> T) where [
pred mem1(S::in, S::out) is det
].
:- typeclass tc2(S, T) <= tc1(S, T) where [
pred mem2(S::in, S::out) is det
].
:- typeclass tc3(S) <= tc1(S, T) where [].
For tc2 shouldn't the compiler be able to infer that T is functionally
dependent on S, so mem2 is fine?
For tc3 why does T need to be in tc3's arguments if it is functionally
dependent on S?
The errors given by the compiler are:
fd.m:016: Error: type variable in superclass constraint is not a
parameter of this type class: tc1(_1, _3).
fd.m:022: Error: type variable in superclass constraint is not a
parameter of this type class: tc1(_1, _2).
fd.m:019: In declaration for predicate `fd.mem2/2':
fd.m:019: error in type class constraints: type variable T occurs in
the
fd.m:019: constraints, but is not determined by the predicate's
argument
fd.m:019: types.
Is there a fundamental reason for these limitations or are they just
not yet implemented (or am I just being stupid ;-)
Cheers,
Ian.
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list