[mercury-users] typeclass error
Ian MacLarty
maclarty at cs.mu.OZ.AU
Thu Jan 19 05:27:13 AEDT 2006
Hello,
What's wrong with the following program?
:- module tc.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module list, int.
main(!IO) :-
nl(!IO).
:- typeclass tc1(A, C) where [
func a_to_c(A) = C
].
:- typeclass tc2(B, C) where [
func b_to_c(B) = C
].
:- func f(A, B) = C <= (tc1(A, C), tc2(B, C)).
f(A, B) =
( if a_to_c(A) = b_to_c(B) then
a_to_c(A)
else
b_to_c(B)
).
I get the following error when I try to compile it:
tc.m:024: In function `tc.f/2':
tc.m:024: type error: unsatisfied typeclass constraints:
tc.m:024: `tc.tc1(A, C)'
tc.m:024: `tc.tc2(B, C)'
tc.m:024: In function `tc.f/2':
tc.m:024: warning: unresolved polymorphism.
tc.m:024: The variable with an unbound type was:
tc.m:024: V_6: C
tc.m:024: The unbound type variable(s) will be implicitly
tc.m:024: bound to the builtin type `void'.
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