[m-rev.] for review: Fix abstract equivalence types.

Julien Fischer jfischer at opturion.com
Wed Aug 23 16:57:11 AEST 2017



On Wed, 23 Aug 2017, Mark Brown wrote:

> Hi Dirk,
>
> On Wed, Aug 23, 2017 at 4:27 PM, Dirk Ziegemeyer <dirk at ziegemeyer.de> wrote:
>> What ist the reason for not using
>> :- type var(T) == int.
>> instead?
>>
>> I suppose that the compiler won’t recognise if we accidentally mix up two types which are both equivalent to int.
>
> That's a good answer to your own question  ;-)

One of the major problems with abstract equivalence types and the reason
why the standard library, in particular, avoids their use is type class
instances.  If, for example, var/1 were defined as:

    :- type var(T) == int.

then ':- instance foo(var(T))' is really an instance declaration for
':- instance foo(int)'.  That's a little unfortunate since in most
contexts var(T)'s are semantically distinct from ints and many type
classes would want to treat them separately.

Julien.


More information about the reviews mailing list