[m-users.] Existential types question
Volker Wysk
post at volker-wysk.de
Wed Mar 8 13:48:59 AEDT 2023
Hi
The following fails to compile:
:- type t ---> some [X] (t(X) => class(X)).
:- typeclass class(X) where [
pred tuwas(X::in, X::out) is det
].
:- instance class(int) where [
tuwas(I, I+1)
].
:- pred nochwas(t::in, t::out) is det.
nochwas(T, U) :-
T = t(X),
tuwas(X,Y),
U = t(Y). % <-- line 28
main(!IO) :-
nochwas('new t'(1), t(Y)),
io.print(Y, !IO).
I get this error message:
test1.m:028: In clause for predicate `nochwas'/2:
test1.m:028: in unification of variable `U'
test1.m:028: and term `t(Y)':
test1.m:028: type error in argument of functor `t'/1.
test1.m:028: Argument 1 (Y) has type
test1.m:028: some [X_1] (X_1),
test1.m:028: expected type was
test1.m:028: some [X_3] (X_3).
I don't understand this message...
TIA,
Volker
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.mercurylang.org/archives/users/attachments/20230308/5b48280d/attachment.sig>
More information about the users
mailing list