[m-users.] Existential types question

Volker Wysk <[email protected]>
Newsgroups gmane.comp.lang.mercury.general
Message-ID <[email protected]>
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

_______________________________________________
users mailing list
[email protected]
https://lists.mercurylang.org/listinfo/users
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEE6QXGh82Ov3+2nrxp+K4ydFOsHoUFAmQH95sACgkQ+K4ydFOs
HoUa9A//Z0WBq1oztqHHbfS4E/29xMc7FdRnoPQHH1N2ksgJ0LXkJO4pyCw1fmIc
gF6rld3Bd53J/Dj6Apt7f1K8ttBUZttUPT6EXzsvnEdzPgwRimmUAY+xlgMAaHty
Y6WaGuIICY9lFQpmJEhlBw8mWusEJYJAIuKfD0hmEfGM7RX3sy/R8Ox5CQAG5VP9
PMFPnwnO1dXZKxEywWXPcUGcPanJLyZJTBBF/VmpsSgQ4TyhlTHjqGoJyduLBw5j
MKMxGlqfTOwAvTl/HLM3VnNmFiMD/FN/CywV7sJavUXRyrIkN2mhKV5r6/biwznw
kkCJIzRfEcLFlMH+UwL5isv/x352RkbazzfWcd0pSNDUD/MMkWU2qPqaCAfFxWx5
XEVU4v4WvVYmr3mvBqSE1P7n3P++CYeKbAbhpzoJ7ASl1eFQyearfFl0wL403k7y
TNRDyVRaiiafJ9Wo484TxFmXPA/FvLRZIPLRQuJr0Ngtu/aMUfCKx9DjFPhWUC5J
gODOlyQj4WUzgRGp+pD3jT7tRWjsdew8mttKN3c1cbFgxB751Z/aWc/e0fjmfeBt
nCYa9cMbMjzAXjkgmCBCqbcgkfuRUPjcSF3zqps8aJ3jLjiTIfCwjoGTKrEfsdMr
AmoE0Oaky3APTO4YYUoozzNpwEMNhz6F+4aZxrVRDl7cmgMMB3k=
=rIhN
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.