[m-users.] Existential types question

Volker Wysk post at volker-wysk.de
Wed Mar 8 13:53:08 AEDT 2023


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
> users at lists.mercurylang.org
> https://lists.mercurylang.org/listinfo/users

-------------- 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/03076ce6/attachment.sig>


More information about the users mailing list