[m-rev.] for review: better error messages for overloaded types
Fergus Henderson
fjh at cs.mu.OZ.AU
Fri Aug 3 20:32:57 AEST 2001
BTW, this is the first change to introduce the use of typeclasses
into the compiler.
On 03-Aug-2001, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> For review by Fergus.
>
> compiler/typecheck.m:
> When printing messages about errors involving overloaded types,
The log message should begin with a summary (e.g. the sentence in
the Subject line would be a good start).
> compiler/check_typeclass.m:
> compiler/prog_util.m:
> Minor changes to conform to the naming scheme now used in
> mercury_to_mercury.m, in particular to the fact the operations of the
> form x_to_string are now functions, not predicates.
>
> The functionality of prog_util should be unaffected. In check_typeclass
> we may now print more detailed error messages than before.
Don't forget to update *.err_exp* in tests/invalid and *.exp* in
tests/warnings to reflect any changes to the warning/error messages.
> library/string.m:
> Declare the outputs append, append_list and join_list to be unique.
If you're going to do that for string__append, you should probably do it
for `++' too.
> library/term_io.m:
> Add alternative versions of some output predicates that return their
> "output" in a string instead.
These changes should be mentioned in the NEWS file.
> Index: compiler/mercury_to_mercury.m
...
> +% as a list of strings that must be conceatenated together at the end using
s/conceatenated/concatenated/
> +:- typeclass output(U) where [
> + pred add_string(string::in, U::di, U::uo) is det,
> + pred add_strings(list(string)::in, U::di, U::uo) is det,
> + pred add_char(char::in, U::di, U::uo) is det,
...
There should be some documentation here, or at least a pointer
to the comments at the top of the file.
> +:- pred output_string(string::in, string::di, string::uo) is det.
> +
> +output_string(S, Str0, Str) :-
> + string__append(Str0, S, Str).
Personally I'd probably write that as
output_string(S, Str, Str ++ S).
and likewise for most of the other output_* methods that call string__append.
But I don't think it is worth changing now, though --
the code you have is fine.
> +overloading.m:050: variable `StartMap0' has overloaded type {
> +overloading.m:050: (pred (tree234:tree234(V_V_1, V_V_2))),
> +overloading.m:050: (tree234:tree234(K, V))
> +overloading.m:050: },
For consistency with other error messages,
the types should be intended two spaces more than the "variable ... has
overloaded type" message, rather than just one space more.
Also the closing '}' should be intended at the same level as the "variable
... has overloaded type" message, rather than one space more.
i.e. it should be
overloading.m:050: variable `StartMap0' has overloaded type {
overloading.m:050: (pred (tree234:tree234(V_V_1, V_V_2))),
overloading.m:050: (tree234:tree234(K, V))
overloading.m:050: },
Otherwise that looks fine. Please post a relative diff.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list