for review: fix .ints for exist + typeclasses.

Tyson Dowd trd at cs.mu.OZ.AU
Tue Aug 4 16:10:23 AEST 1998


Hi,

Fergus and DJ should take a look at this to make sure I've done
it right.

===================================================================


Estimated hours taken: 1

Fix a bug in the generation of .int declarations for preds/funcs with
existential types and type classes.

compiler/mercury_to_mercury.m:
	Generate
		:- some [T] (func foo:bar = T & (foo:baz(T))).
	instead of
		:- some [T] func foo:bar = T & (foo:baz(T)).


Index: compiler/mercury_to_mercury.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_to_mercury.m,v
retrieving revision 1.139
diff -u -r1.139 mercury_to_mercury.m
--- mercury_to_mercury.m	1998/07/08 20:56:50	1.139
+++ mercury_to_mercury.m	1998/08/04 05:58:37
@@ -1167,6 +1167,14 @@
 
 	mercury_output_quantifier(VarSet, ExistQVars),
 
+	(
+		{ ExistQVars = [] }
+	->
+		[]
+	;
+		io__write_string("(")
+	),
+
 	% we need to quote ';'/2, '{}'/2, '&'/2, and 'some'/2
 	{ list__length(Args, Arity) },
 	(
@@ -1205,7 +1213,14 @@
 		[]
 	),
 
-	mercury_output_class_constraint_list(Constraints, VarSet, "&").
+	mercury_output_class_constraint_list(Constraints, VarSet, "&"),
+	(
+		{ ExistQVars = [] }
+	->
+		[]
+	;
+		io__write_string(")")
+	).
 
 :- pred mercury_output_ctor_arg(varset, constructor_arg, io__state, io__state).
 :- mode mercury_output_ctor_arg(in, in, di, uo) is det.
@@ -1277,6 +1292,11 @@
 		Purity, ClassContext, _Context, StartString, Separator) -->
 	io__write_string(StartString),
 	mercury_output_quantifier(VarSet, ExistQVars),
+	( { ExistQVars = [] } -> 
+		[] 
+	; 
+		io__write_string("(")
+	),
 	write_purity_prefix(Purity),
 	io__write_string("pred "),
 	(
@@ -1287,10 +1307,20 @@
 		mercury_output_term(Type, VarSet, no),
 		mercury_output_remaining_terms(Rest, VarSet, no),
 		io__write_string(")"),
-		mercury_output_class_context(ClassContext, VarSet)
+		mercury_output_class_context(ClassContext, VarSet),
+		( { ExistQVars = [] } -> 
+			[] 
+		; 
+			io__write_string(")")
+		)
 	;
 		mercury_output_bracketed_sym_name(PredName),
 		mercury_output_class_context(ClassContext, VarSet),
+		( { ExistQVars = [] } -> 
+			[] 
+		; 
+			io__write_string(")")
+		),
 		mercury_output_det_annotation(MaybeDet)
 	),
 
@@ -1365,6 +1395,11 @@
 		Separator) -->
 	io__write_string(StartString),
 	mercury_output_quantifier(VarSet, ExistQVars),
+	( { ExistQVars = [] } -> 
+		[] 
+	; 
+		io__write_string("(")
+	),
 	write_purity_prefix(Purity),
 	io__write_string("func "),
 	(
@@ -1381,6 +1416,11 @@
 	io__write_string(" = "),
 	mercury_output_term(RetType, VarSet, no),
 	mercury_output_class_context(ClassContext, VarSet),
+	( { ExistQVars = [] } -> 
+		[] 
+	; 
+		io__write_string(")")
+	),
 	mercury_output_det_annotation(MaybeDet),
 	io__write_string(Separator).
 


-- 
       Tyson Dowd           # There isn't any reason why Linux can't be
                            # implemented as an enterprise computing solution.
     trd at cs.mu.oz.au        # Find out what you've been missing while you've
http://www.cs.mu.oz.au/~trd # been rebooting Windows NT. -- InfoWorld, 1998.



More information about the developers mailing list