[m-rev.] diff: relax restrictions on existential data
Mark Brown
mark at cs.mu.OZ.AU
Fri May 13 21:30:14 AEST 2005
On 13-May-2005, Julien Fischer <juliensf at cs.mu.OZ.AU> wrote:
> Just an observation: with things like this the compiler should provide
> more of an explanation when compiling with -E.
Good idea.
Cheers,
Mark.
Estimated hours taken: 0.5
Branches: main
compiler/check_typeclass.m:
Add a verbose error message to explain what is meant by a type
variable being "determined" by the arguments of a predicate, function
or constructor.
Index: compiler/check_typeclass.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/check_typeclass.m,v
retrieving revision 1.74
diff -u -r1.74 check_typeclass.m
--- compiler/check_typeclass.m 13 May 2005 02:24:07 -0000 1.74
+++ compiler/check_typeclass.m 13 May 2005 11:28:02 -0000
@@ -1732,6 +1732,7 @@
Msg = Msg0 ++ [words("function's argument or result types.")]
),
write_error_pieces(Context, 0, Msg, !IO),
+ maybe_report_unbound_tvars_explanation(Context, !IO),
io__set_exit_status(1, !IO).
:- pred report_unbound_tvars_in_ctor_context(list(tvar)::in, type_ctor::in,
@@ -1757,7 +1758,48 @@
words(choose_number(Vars, "is", "are")),
words("not determined by the constructor's argument types.")],
write_error_pieces(Context, 0, Msg, !IO),
+ maybe_report_unbound_tvars_explanation(Context, !IO),
io__set_exit_status(1, !IO).
+
+:- pred maybe_report_unbound_tvars_explanation(prog_context::in,
+ io::di, io::uo) is det.
+
+maybe_report_unbound_tvars_explanation(Context, !IO) :-
+ globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
+ (
+ VerboseErrors = yes,
+ Msg = [words("All types occurring in typeclass constraints"),
+ words("must be fully determined."),
+ words("A type is fully determined if one of the"),
+ words("following holds:"),
+ nl,
+ words("1) All type variables occurring in the type"),
+ words("are determined."),
+ nl,
+ words("2) The type occurs in a constraint argument,"),
+ words("that argument is in the range of some"),
+ words("functional dependency for that class, and"),
+ words("the types in all of the domain arguments for"),
+ words("that functional dependency are fully"),
+ words("determined."),
+ nl,
+ words("A type variable is determined if one of the"),
+ words("following holds:"),
+ nl,
+ words("1) The type variable occurs in the argument"),
+ words("types of the predicate, function, or"),
+ words("constructor which is constrained."),
+ nl,
+ words("2) The type variable occurs in a type which"),
+ words("is fully determined."),
+ nl,
+ words("See the ""Functional dependencies"" section"),
+ words("of the reference manual for details.")
+ ],
+ write_error_pieces_not_first_line(Context, 0, Msg, !IO)
+ ;
+ VerboseErrors = no
+ ).
%---------------------------------------------------------------------------%
%
--------------------------------------------------------------------------
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