[m-rev.] for review: improve doc and error messages for existentially typed data

Zoltan Somogyi zoltan.somogyi at runbox.com
Wed May 6 15:37:02 AEST 2020


2020-05-06 13:57 GMT+10:00 Julien Fischer<jfischer at opturion.com>:
>> @@ -584,14 +587,14 @@ process_du_ctors(Params, VarSet, BodyTerm, [Ctor | Ctors], !Specs) :-
>>          NotOccursExistQVarStrs =
>>              list.map(mercury_var_to_name_only(GenericVarSet),
>>              NotOccursExistQVars),
>> -        Pieces = [words("Error:"),
>> +        Pieces = [words("Error: the existentialy quantified"),
> 
> s/existentialy/existentially/
> (And also in the expected output for the test of this message).

Done.
 
>>      --->    some [T] (s(T) => showable(T)).
>>  :- type list_of_showable == list(showable).
>> > -% Here's an arbitrary example involving multiple
>> -% type variables and multiple constraints.
>> +% Here is an arbitrary example involving multiple type variables
>> +% and multiple constraints.
>>  :- typeclass foo(T1, T2) where [ /* @dots{} */ ].
>>  :- type bar(T)
>>      --->    f1
>>      ;       f2(T)
>> -    ;       some [T]
>> -            f4(T)
>> -    ;       some [T1, T2]
>> -            (f4(T1, T2, T) => showable(T1), showable(T2))
>> -    ;       some [T1, T2]
>> -            (f5(list(T1), T2) => fooable(T1, list(T2))).
>> +    ;       some [T1] f3(T1)
>> +    ;       some [T1, T2] f4(T1, T2, T) => (showable(T1), showable(T2))
>> +    ;       some [T1, T2] f5(list(T1), T2) => fooable(T1, list(T2)).
>>  @end example
> 
> That last case is using behaviour we don't yet support, the constraint
> fooable(T1, list(T2)) will result in the error:
> 
>    Sorry, not implemented: constraints may only constrain type
>    variables and ground types

So that one block of example code had a *third* bug, besides a duplicate
function symbol name and shadowing a type variable? Holy cow!

> I suggest replacing it with something the current compiler will acccept.

Done, and I also added a test for the error message for the original,
buggy constraint to the new test case. Then I fixed that error message
as well by adding the missing final period.

Thanks for the review.

Zoltan.


More information about the reviews mailing list