Re: [m-users.] Existential types question

Volker Wysk <[email protected]>
Newsgroups gmane.comp.lang.mercury.general
Message-ID <[email protected]>
Sorry for the noise, I found it. The "U = t(Y)" should be "U = 'new t'(Y)".

Volker


Am Mittwoch, dem 08.03.2023 um 03:48 +0100 schrieb Volker Wysk:
> 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

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

iQIzBAABCgAdFiEE6QXGh82Ov3+2nrxp+K4ydFOsHoUFAmQH+JQACgkQ+K4ydFOs
HoWnDBAAqfyhEDEV/ym/ILFe0w7zHX6XiOZPmNISlNLZ/PzmT/UVLyjN9YB50zS5
skEIe/3OjJ+jRG4ZHDrJ81x6Ww9UEDz/E4yDUo5W9XNmmJT2NFpSwQpE9coc/k1y
thMMGwYLaFj5usG+PmNgOFITc2EIXhZbTGoVdXW25ecZNQlzBr5wCR3KB3sBaLao
CVb0U9jtfsczX4L9Z4GNijZjRBSg46wWY1hBuH4oAJFxTsX0gda3oeFrXAViWdor
/INgL0Nfak3YKb90mNwsxzDAlWmuHxnSeI9vrys1AFKvkI+k1+H4Ub32QhYIBjcv
FGpQ7zFsYuR/1XjNlOnonVHgBaWv3GkzQdQ9ukUk6E9itjFdI9ZVAkXG/OKN2mmo
5aXcYSyM5fdTtzF09H/KsFAAs3bdYKsU7Z+M3JZElG4a/ZXgTtaf0/flKclqeHIn
tvgTUKtbQzFOoXe+59kA71GQtyEDK4/QZ9Mw2+p0foR1Ajm4U8kGJ/jkuxDO1Asz
/GCdIhHX0vuTmMCwpwYI+dcuCaXE5sBjpyyvUfoOjhZOJcNfaeh9/SOhEumdKblN
AJ/NHr3svPmdGdzoKAwu0xobjCluaMwzfzmvj4FlGso74YzlUg9HcBUfo/Wh1C4c
kb8bqTHIKj4cbjQEY+ZnMPJMTEzMEpcha+QEBMv810o6v1Ift9o=
=wrmU
-----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.