[m-rev.] diff: moving cons_id to prog_data.m (part 1 of 2)

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Jun 14 14:18:54 AEST 2004


Remove almost all dependencies by the modules of parse_tree.m on the modules
of hlds.m. The only such dependencies remaining now are on type_util.m.

compiler/hlds_data.m:
compiler/prog_data.m:
	Move the cons_id type from hlds_data to prog_data, since several parts
	of the parse tree data structure depend on it (particularly insts).
	Remove the need to import HLDS modules in prog_data.m by making the
	cons_ids that refer to procedure ids refer to them via a new type
	that contains shrouded pred_ids and proc_ids. Since pred_ids and
	proc_ids are abstract types in hlds_data, add predicates to hlds_data
	to shroud and unshroud them.

	Also move some other types, e.g. mode_id and class_id, from hlds_data
	to prog_data.

compiler/hlds_data.m:
compiler/prog_util.m:
	Move predicates for manipulating cons_ids from hlds_data to prog_util.

compiler/inst.m:
compiler/prog_data.m:
	Move the contents of inst.m to prog_data.m, since that is where it
	belongs, and since doing so eliminates a circular dependency.
	The separation doesn't serve any purpose any more, since we don't
	need to import hlds_data.m anymore to get access to the cons_id type.

compiler/mode_util.m:
compiler/prog_mode.m:
compiler/parse_tree.m:
	Move the predicates in mode_util that don't depend on the HLDS to a new
	module prog_mode, which is part of parse_tree.m.

compiler/notes/compiler_design.m:
	Mention prog_mode.m, and delete the mention of inst.m.

compiler/mercury_to_mercury.m:
compiler/hlds_out.m:
	Move the predicates that depend on HLDS out of mercury_to_mercury.m
	to hlds_out.m. Export from mercury_to_mercury.m the predicates needed
	by the moved predicates.

compiler/hlds_out.m:
compiler/prog_out.m:
	Move predicates for printing parts of the parse tree out of hlds_out.m
	to prog_out.m, since mercury_to_mercury.m needs to use them.

compiler/purity.m:
compiler/prog_out.m:
	Move predicates for printing purities from purity.m, which is part
	of check_hlds.m, to prog_out.m, since mercury_to_mercury.m needs to use
	them.

compiler/passes_aux.m:
compiler/prog_out.m:
	Move some utility predicates (e.g. for printing progress messages) from
	passes_aux.m to prog_out.m, since some predicates in submodules of
	parse_tree.m need to use them.

compiler/foreign.m:
compiler/prog_data.m:
	Move some types from foreign.m to prog_data.m to allow the elimination
	of some dependencies on foreign.m from submodules of parse_tree.m.

compiler/*.m:
	Conform to the changes above, mostly by updating lists of imported
	modules and module qualifications. In some cases, also do some local
	cleanups such as converting predicate declarations to predmode syntax
	and fixing white space.

Zoltan.

cvs diff: Diffing .
Index: accumulator.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/accumulator.m,v
retrieving revision 1.30
diff -u -b -r1.30 accumulator.m
--- accumulator.m	20 May 2004 22:18:30 -0000	1.30
+++ accumulator.m	12 Jun 2004 16:12:45 -0000
@@ -158,7 +158,6 @@
 :- implementation.
 
 :- import_module check_hlds__inst_match.
-:- import_module check_hlds__mode_util.
 :- import_module hlds__assertion.
 :- import_module hlds__goal_util.
 :- import_module hlds__hlds_data.
@@ -170,8 +169,8 @@
 :- import_module libs__globals.
 :- import_module libs__options.
 :- import_module parse_tree__error_util.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__prog_data.
+:- import_module parse_tree__prog_mode.
 :- import_module parse_tree__prog_util.
 :- import_module transform_hlds__goal_store.
 
Index: add_heap_ops.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/add_heap_ops.m,v
retrieving revision 1.12
diff -u -b -r1.12 add_heap_ops.m
--- add_heap_ops.m	7 Jun 2004 09:06:26 -0000	1.12
+++ add_heap_ops.m	12 Jun 2004 10:05:00 -0000
@@ -47,7 +47,6 @@
 :- import_module hlds__hlds_goal.
 :- import_module hlds__instmap.
 :- import_module hlds__quantification.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__modules.
 :- import_module parse_tree__prog_data.
 :- import_module parse_tree__prog_util.
Index: add_trail_ops.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/add_trail_ops.m,v
retrieving revision 1.14
diff -u -b -r1.14 add_trail_ops.m
--- add_trail_ops.m	7 Jun 2004 09:06:27 -0000	1.14
+++ add_trail_ops.m	12 Jun 2004 10:05:00 -0000
@@ -46,7 +46,6 @@
 :- import_module hlds__hlds_goal.
 :- import_module hlds__instmap.
 :- import_module hlds__quantification.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__modules.
 :- import_module parse_tree__prog_data.
 :- import_module parse_tree__prog_util.
Index: aditi_backend.pp
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/aditi_backend.pp,v
retrieving revision 1.6
diff -u -b -r1.6 aditi_backend.pp
--- aditi_backend.pp	23 Mar 2004 10:52:00 -0000	1.6
+++ aditi_backend.pp	13 Jun 2004 07:33:51 -0000
@@ -11,7 +11,9 @@
 
 :- import_module hlds.
 
-%:- import_module aditi_hlds, aditi_codegen, aditi_rl_out.
+% :- import_module aditi_hlds.
+% :- import_module aditi_codegen.
+% :- import_module aditi_rl_out.
 
 %
 % Phase 4-rl: Aditi-related HLDS transformations
Index: aditi_builtin_ops.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/aditi_builtin_ops.m,v
retrieving revision 1.8
diff -u -b -r1.8 aditi_builtin_ops.m
--- aditi_builtin_ops.m	7 Jun 2004 09:06:27 -0000	1.8
+++ aditi_builtin_ops.m	12 Jun 2004 14:19:28 -0000
@@ -41,8 +41,8 @@
 :- import_module hlds__instmap.
 :- import_module hlds__passes_aux.
 :- import_module hlds__quantification.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__prog_data.
+:- import_module parse_tree__prog_mode.
 :- import_module parse_tree__prog_out.
 :- import_module parse_tree__prog_util.
 
@@ -99,7 +99,9 @@
 	{ Goal0 = unify(_, _, _, Unification, _) },
 	(
 		{ Unification = construct(Var, ConsId, Args, _, _, _, _) },
-		{ ConsId = pred_const(PredId, ProcId, aditi_bottom_up) }
+		{ ConsId = pred_const(ShroudedPredProcId, aditi_bottom_up) },
+		{ proc(PredId, ProcId) =
+			unshroud_pred_proc_id(ShroudedPredProcId) }
 	->
 		^ changed := yes,
 		transform_aditi_bottom_up_closure(Var, PredId, ProcId,
@@ -229,7 +231,9 @@
 	{ UniMode = ((free_inst - CastInputInst) ->
 			(CastInputInst - CastInputInst)) },
 	{ list__duplicate(NumBuiltinArgs, UniMode, UniModes) },
-	{ BuiltinConsId = pred_const(BuiltinPredId, BuiltinProcId, normal) },
+	{ ShroudedPredProcId = shroud_pred_proc_id(
+		proc(BuiltinPredId, BuiltinProcId)) },
+	{ BuiltinConsId = pred_const(ShroudedPredProcId, normal) },
 	{ Unification = construct(NewVar, BuiltinConsId, BuiltinArgs,
 			UniModes, construct_dynamically,
 			cell_is_unique, no) },
Index: arg_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/arg_info.m,v
retrieving revision 1.42
diff -u -b -r1.42 arg_info.m
Index: base_typeclass_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/base_typeclass_info.m,v
retrieving revision 1.28
diff -u -b -r1.28 base_typeclass_info.m
Index: basic_block.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/basic_block.m,v
retrieving revision 1.16
diff -u -b -r1.16 basic_block.m
Index: bytecode.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/bytecode.m,v
retrieving revision 1.54
diff -u -b -r1.54 bytecode.m
Index: bytecode_data.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/bytecode_data.m,v
retrieving revision 1.13
diff -u -b -r1.13 bytecode_data.m
Index: bytecode_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/bytecode_gen.m,v
retrieving revision 1.82
diff -u -b -r1.82 bytecode_gen.m
--- bytecode_gen.m	7 Jun 2004 09:06:27 -0000	1.82
+++ bytecode_gen.m	12 Jun 2004 10:06:54 -0000
@@ -735,7 +735,9 @@
 		ConsId = float_const(FloatVal),
 		ByteConsId = float_const(FloatVal)
 	;
-		ConsId = pred_const(PredId, ProcId, EvalMethod),
+		ConsId = pred_const(ShroudedPredProcId, EvalMethod),
+		proc(PredId, ProcId) =
+			unshroud_pred_proc_id(ShroudedPredProcId),
 		( EvalMethod = normal ->
 			predicate_id(ModuleInfo, PredId,
 				ModuleName, PredName, Arity),
@@ -748,7 +750,8 @@
 				PredName, Arity, IsFunc, ProcInt)
 		;
 			% XXX
-			sorry(this_file, "bytecode for Aditi lambda expressions")
+			sorry(this_file,
+				"bytecode for Aditi lambda expressions")
 		)
 	;
 		ConsId = type_ctor_info_const(ModuleName, TypeName, TypeArity),
@@ -766,7 +769,7 @@
 		ConsId = typeclass_info_cell_constructor,
 		ByteConsId = typeclass_info_cell_constructor
 	;
-		ConsId = tabling_pointer_const(_, _),
+		ConsId = tabling_pointer_const(_),
 		sorry(this_file, "bytecode cannot implement tabling")
 	;
 		ConsId = table_io_decl(_),
@@ -806,10 +809,10 @@
 bytecode_gen__map_cons_tag(tabling_pointer_constant(_, _), _) :-
 	unexpected(this_file, "tabling_pointer_constant cons tag " ++
 		"for non-tabling_pointer_constant cons id").
-bytecode_gen__map_cons_tag(deep_profiling_proc_layout_tag(_), _) :-
+bytecode_gen__map_cons_tag(deep_profiling_proc_layout_tag(_, _), _) :-
 	unexpected(this_file, "deep_profiling_proc_layout_tag cons tag " ++
 		"for non-deep_profiling_proc_static cons id").
-bytecode_gen__map_cons_tag(table_io_decl_tag(_), _) :-
+bytecode_gen__map_cons_tag(table_io_decl_tag(_, _), _) :-
 	unexpected(this_file, "table_io_decl_tag cons tag " ++
 		"for non-table_io_decl cons id").
 bytecode_gen__map_cons_tag(reserved_address(_), _) :-
Index: c_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/c_util.m,v
retrieving revision 1.19
diff -u -b -r1.19 c_util.m
Index: call_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/call_gen.m,v
retrieving revision 1.159
diff -u -b -r1.159 call_gen.m
Index: check_hlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/check_hlds.m,v
retrieving revision 1.4
diff -u -b -r1.4 check_hlds.m
Index: clause_to_proc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/clause_to_proc.m,v
retrieving revision 1.41
diff -u -b -r1.41 clause_to_proc.m
--- clause_to_proc.m	7 Jun 2004 09:06:28 -0000	1.41
+++ clause_to_proc.m	12 Jun 2004 14:21:38 -0000
@@ -49,13 +49,13 @@
 
 :- implementation.
 
-:- import_module check_hlds__mode_util.
 :- import_module check_hlds__purity.
 :- import_module hlds__hlds_data.
 :- import_module hlds__hlds_goal.
 :- import_module hlds__make_hlds.
 :- import_module libs__globals.
 :- import_module parse_tree__prog_data.
+:- import_module parse_tree__prog_mode.
 
 :- import_module assoc_list, bool, int, set, map, varset, require.
 
Index: code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_gen.m,v
retrieving revision 1.127
diff -u -b -r1.127 code_gen.m
Index: code_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_util.m,v
retrieving revision 1.152
diff -u -b -r1.152 code_util.m
Index: common.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/common.m,v
retrieving revision 1.72
diff -u -b -r1.72 common.m
--- common.m	23 May 2004 22:09:16 -0000	1.72
+++ common.m	12 Jun 2004 10:05:01 -0000
@@ -93,7 +93,6 @@
 :- import_module hlds__quantification.
 :- import_module libs__globals.
 :- import_module libs__options.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__prog_util.
 :- import_module transform_hlds__pd_cost.
 
Index: const_prop.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/const_prop.m,v
retrieving revision 1.24
diff -u -b -r1.24 const_prop.m
--- const_prop.m	5 Apr 2004 05:06:45 -0000	1.24
+++ const_prop.m	12 Jun 2004 10:05:01 -0000
@@ -22,8 +22,12 @@
 
 :- interface.
 
-:- import_module hlds__hlds_module, hlds__hlds_goal, hlds__hlds_pred.
-:- import_module parse_tree__prog_data, hlds__instmap.
+:- import_module hlds__hlds_goal.
+:- import_module hlds__hlds_module.
+:- import_module hlds__hlds_pred.
+:- import_module hlds__instmap.
+:- import_module parse_tree__prog_data.
+
 :- import_module list.
 
 	% evaluate_call(PredId, ProcId, Args, GoalInfo0,
@@ -57,7 +61,6 @@
 :- import_module hlds__quantification.
 :- import_module libs__globals.
 :- import_module libs__options.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__prog_data.
 
 :- import_module bool, list, int, float, map, require, string.
Index: constraint.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/constraint.m,v
retrieving revision 1.55
diff -u -b -r1.55 constraint.m
Index: context.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/context.m,v
retrieving revision 1.8
diff -u -b -r1.8 context.m
--- context.m	24 Oct 2003 06:17:35 -0000	1.8
+++ context.m	12 Jun 2004 10:05:01 -0000
@@ -55,7 +55,6 @@
 :- import_module hlds__hlds_data.
 :- import_module hlds__hlds_module.
 :- import_module hlds__instmap.
-:- import_module parse_tree__inst.
 
 :- import_module assoc_list, bool, map, require, set, std_util, term, varset.
 
Index: continuation_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/continuation_info.m,v
retrieving revision 1.53
diff -u -b -r1.53 continuation_info.m
--- continuation_info.m	23 May 2004 23:14:24 -0000	1.53
+++ continuation_info.m	12 Jun 2004 10:05:01 -0000
@@ -61,7 +61,6 @@
 :- import_module ll_backend__layout.
 :- import_module ll_backend__llds.
 :- import_module ll_backend__trace.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__prog_data.
 
 :- import_module bool, std_util, list, assoc_list, set, map.
Index: cse_detection.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/cse_detection.m,v
retrieving revision 1.78
diff -u -b -r1.78 cse_detection.m
Index: dead_proc_elim.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/dead_proc_elim.m,v
retrieving revision 1.91
diff -u -b -r1.91 dead_proc_elim.m
--- dead_proc_elim.m	7 Jun 2004 09:06:34 -0000	1.91
+++ dead_proc_elim.m	12 Jun 2004 10:05:02 -0000
@@ -459,7 +459,9 @@
 	(
 		Uni = construct(_, ConsId, _, _, _, _, _),
 		(
-			ConsId = pred_const(PredId, ProcId, _),
+			ConsId = pred_const(ShroudedPredProcId, _),
+			proc(PredId, ProcId) =
+				unshroud_pred_proc_id(ShroudedPredProcId),
 			Entity = proc(PredId, ProcId)
 		;
 			ConsId = type_ctor_info_const(Module, TypeName, Arity),
Index: deep_profiling.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/deep_profiling.m,v
retrieving revision 1.25
diff -u -b -r1.25 deep_profiling.m
--- deep_profiling.m	7 Jun 2004 09:06:34 -0000	1.25
+++ deep_profiling.m	12 Jun 2004 10:07:32 -0000
@@ -38,7 +38,6 @@
 :- import_module libs__options.
 :- import_module ll_backend__code_util.
 :- import_module ll_backend__trace.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__prog_data.
 :- import_module parse_tree__prog_util.
 :- import_module transform_hlds.
@@ -598,11 +597,11 @@
 		PredProcId = proc(PredId, ProcId)
 	),
 
-	RttiProcLabel = rtti__make_rtti_proc_label(ModuleInfo, PredId, ProcId),
 	IsInInterface = is_proc_in_interface(ModuleInfo, PredId, ProcId),
 	ProcStatic = hlds_proc_static(FileName, LineNumber, IsInInterface,
 		CallSites),
-	ProcStaticConsId = deep_profiling_proc_layout(RttiProcLabel),
+	ShroudedPredProcId = shroud_pred_proc_id(proc(PredId, ProcId)),
+	ProcStaticConsId = deep_profiling_proc_layout(ShroudedPredProcId),
 	generate_unify(ProcStaticConsId, ProcStaticVar, BindProcStaticVarGoal),
 
 	(
@@ -693,11 +692,11 @@
 		PredProcId = proc(PredId, ProcId)
 	),
 
-	RttiProcLabel = rtti__make_rtti_proc_label(ModuleInfo, PredId, ProcId),
 	IsInInterface = is_proc_in_interface(ModuleInfo, PredId, ProcId),
 	ProcStatic = hlds_proc_static(FileName, LineNumber,
 		IsInInterface, CallSites),
-	ProcStaticConsId = deep_profiling_proc_layout(RttiProcLabel),
+	ShroudedPredProcId = shroud_pred_proc_id(proc(PredId, ProcId)),
+	ProcStaticConsId = deep_profiling_proc_layout(ShroudedPredProcId),
 	generate_unify(ProcStaticConsId, ProcStaticVar, BindProcStaticVarGoal),
 
 	(
@@ -800,11 +799,11 @@
 	CallSites = DeepInfo ^ call_sites,
 
 	PredProcId = proc(PredId, ProcId),
-	RttiProcLabel = rtti__make_rtti_proc_label(ModuleInfo, PredId, ProcId),
 	IsInInterface = is_proc_in_interface(ModuleInfo, PredId, ProcId),
 	ProcStatic = hlds_proc_static(FileName, LineNumber,
 		IsInInterface, CallSites),
-	ProcStaticConsId = deep_profiling_proc_layout(RttiProcLabel),
+	ShroudedPredProcId = shroud_pred_proc_id(proc(PredId, ProcId)),
+	ProcStaticConsId = deep_profiling_proc_layout(ShroudedPredProcId),
 	generate_unify(ProcStaticConsId, ProcStaticVar, BindProcStaticVarGoal),
 
 	(
Index: deforest.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/deforest.m,v
retrieving revision 1.37
diff -u -b -r1.37 deforest.m
--- deforest.m	7 Jun 2004 09:06:35 -0000	1.37
+++ deforest.m	12 Jun 2004 10:05:02 -0000
@@ -63,7 +63,6 @@
 :- import_module hlds__quantification.
 :- import_module libs__globals.
 :- import_module libs__options.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__prog_data.
 :- import_module parse_tree__prog_out.
 :- import_module parse_tree__prog_util.
Index: delay_construct.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/delay_construct.m,v
retrieving revision 1.7
diff -u -b -r1.7 delay_construct.m
Index: dense_switch.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/dense_switch.m,v
retrieving revision 1.48
diff -u -b -r1.48 dense_switch.m
Index: dependency_graph.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/dependency_graph.m,v
retrieving revision 1.71
diff -u -b -r1.71 dependency_graph.m
--- dependency_graph.m	7 Jun 2004 09:06:35 -0000	1.71
+++ dependency_graph.m	12 Jun 2004 10:05:02 -0000
@@ -483,14 +483,15 @@
 dependency_graph__add_arcs_in_cons(int_const(_), _Caller, !DepGraph).
 dependency_graph__add_arcs_in_cons(string_const(_), _Caller, !DepGraph).
 dependency_graph__add_arcs_in_cons(float_const(_), _Caller, !DepGraph).
-dependency_graph__add_arcs_in_cons(pred_const(Pred, Proc, _), Caller,
+dependency_graph__add_arcs_in_cons(pred_const(ShroudedPredProcId, _), Caller,
 		!DepGraph) :-
+	PredProcId = unshroud_pred_proc_id(ShroudedPredProcId),
 	(
 			% If the node isn't in the relation, then
 			% we didn't insert it because is was imported,
 			% and we don't consider it.
 		relation__search_element(!.DepGraph,
-			dependency_node(proc(Pred, Proc)), Callee)
+			dependency_node(PredProcId), Callee)
 	->
 		relation__add(!.DepGraph, Caller, Callee, !:DepGraph)
 	;
@@ -504,7 +505,7 @@
 		_Caller, !DepGraph).
 dependency_graph__add_arcs_in_cons(typeclass_info_cell_constructor,
 		_Caller, !DepGraph).
-dependency_graph__add_arcs_in_cons(tabling_pointer_const(_, _),
+dependency_graph__add_arcs_in_cons(tabling_pointer_const(_),
 		_Caller, !DepGraph).
 dependency_graph__add_arcs_in_cons(deep_profiling_proc_layout(_),
 		_Caller, !DepGraph).
@@ -813,11 +814,11 @@
 	aditi_scc_info_handle_call(IsNeg, PredId, ProcId, Args, !.Map, !Info).
 process_aditi_goal(_IsNeg, unify(Var, _, _, Unify, _) - _, !Map, !Info) :-
 	(
-		Unify = construct(_, pred_const(PredId, ProcId, _),
+		Unify = construct(_, pred_const(ShroudedPredProcId, _),
 			_, _, _, _, _)
 	->
-		aditi_scc_info_add_closure(Var, proc(PredId, ProcId),
-			!Map, !Info)
+		PredProcId = unshroud_pred_proc_id(ShroudedPredProcId),
+		aditi_scc_info_add_closure(Var, PredProcId, !Map, !Info)
 	;
 		true
 	).
Index: det_analysis.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/det_analysis.m,v
retrieving revision 1.168
diff -u -b -r1.168 det_analysis.m
--- det_analysis.m	7 Jun 2004 09:06:36 -0000	1.168
+++ det_analysis.m	12 Jun 2004 10:05:02 -0000
@@ -135,6 +135,7 @@
 :- import_module hlds__passes_aux.
 :- import_module libs__options.
 :- import_module parse_tree__mercury_to_mercury.
+:- import_module parse_tree__prog_out.
 
 :- import_module string, assoc_list, bool, map, set, require, term.
 
Index: det_report.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/det_report.m,v
retrieving revision 1.89
diff -u -b -r1.89 det_report.m
--- det_report.m	7 Jun 2004 09:06:36 -0000	1.89
+++ det_report.m	12 Jun 2004 15:00:59 -0000
@@ -142,7 +142,9 @@
 :- import_module libs__options.
 :- import_module parse_tree__mercury_to_mercury.
 :- import_module parse_tree__error_util.
+:- import_module parse_tree__prog_mode.
 :- import_module parse_tree__prog_out.
+:- import_module parse_tree__prog_util.
 
 :- import_module assoc_list, bool, int, map, set, std_util, require, string.
 :- import_module getopt, term, varset.
Index: det_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/det_util.m,v
retrieving revision 1.26
diff -u -b -r1.26 det_util.m
--- det_util.m	31 Mar 2004 08:52:22 -0000	1.26
+++ det_util.m	12 Jun 2004 15:00:17 -0000
@@ -84,9 +84,10 @@
 :- implementation.
 
 :- import_module check_hlds__inst_match.
-:- import_module check_hlds__mode_util.
 :- import_module check_hlds__type_util.
 :- import_module libs__options.
+:- import_module parse_tree__prog_mode.
+:- import_module parse_tree__prog_util.
 
 :- import_module map, term, require, std_util.
 
Index: disj_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/disj_gen.m,v
retrieving revision 1.80
diff -u -b -r1.80 disj_gen.m
Index: dnf.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/dnf.m,v
retrieving revision 1.54
diff -u -b -r1.54 dnf.m
--- dnf.m	7 Jun 2004 09:06:37 -0000	1.54
+++ dnf.m	12 Jun 2004 10:05:02 -0000
@@ -511,9 +511,10 @@
 	dnf__cases_free_of_nonatomic(Cases, NonAtomic).
 dnf__free_of_nonatomic(unify(_, _, _, Uni, _) - _, NonAtomic) :-
 	\+ (
-		Uni = construct(_, pred_const(PredId, ProcId, _),
+		Uni = construct(_, pred_const(ShroudedPredProcId, _),
 			_, _, _, _, _),
-		set__member(proc(PredId, ProcId), NonAtomic)
+		PredProcId = unshroud_pred_proc_id(ShroudedPredProcId),
+		set__member(PredProcId, NonAtomic)
 	).
 dnf__free_of_nonatomic(disj(Goals) - GoalInfo, NonAtomic) :-
 		% For Aditi, nondet disjunctions are non-atomic, 
Index: equiv_type.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/equiv_type.m,v
retrieving revision 1.37
diff -u -b -r1.37 equiv_type.m
--- equiv_type.m	7 Jun 2004 09:06:37 -0000	1.37
+++ equiv_type.m	12 Jun 2004 13:45:40 -0000
@@ -91,12 +91,10 @@
 :- implementation.
 
 % XXX we shouldn't import the HLDS here.
-:- import_module check_hlds__mode_util.
 :- import_module check_hlds__type_util.
-:- import_module hlds__hlds_data.
 :- import_module parse_tree__error_util.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__prog_data.
+:- import_module parse_tree__prog_mode.
 :- import_module parse_tree__prog_out.
 :- import_module parse_tree__prog_util.
 
Index: equiv_type_hlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/equiv_type_hlds.m,v
retrieving revision 1.5
diff -u -b -r1.5 equiv_type_hlds.m
--- equiv_type_hlds.m	7 Jun 2004 09:06:38 -0000	1.5
+++ equiv_type_hlds.m	12 Jun 2004 10:05:02 -0000
@@ -33,7 +33,6 @@
 :- import_module hlds__instmap.
 :- import_module hlds__quantification.
 :- import_module parse_tree__equiv_type.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__prog_data.
 :- import_module recompilation.
 
Index: export.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/export.m,v
retrieving revision 1.78
diff -u -b -r1.78 export.m
--- export.m	9 Jun 2004 07:56:10 -0000	1.78
+++ export.m	12 Jun 2004 14:20:46 -0000
@@ -80,6 +80,7 @@
 :- import_module libs__options.
 :- import_module parse_tree__error_util.
 :- import_module parse_tree__modules.
+:- import_module parse_tree__prog_util.
 
 :- import_module term, varset.
 :- import_module library, map, int, string, std_util, assoc_list, require.
Index: fact_table.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/fact_table.m,v
retrieving revision 1.53
diff -u -b -r1.53 fact_table.m
--- fact_table.m	5 Apr 2004 05:06:47 -0000	1.53
+++ fact_table.m	12 Jun 2004 10:05:02 -0000
@@ -400,7 +400,7 @@
 				ProcStreams, MaybeOutput, FactNum, Result,
 				!Errors, !IO)
 		;
-			PFStr = hlds_out__pred_or_func_to_full_str(PredOrFunc),
+			PFStr = pred_or_func_to_full_str(PredOrFunc),
 			string__format("Error: invalid clause for %s `%s/%d'.",
 				[s(PFStr), s(PredString), i(Arity0)], Msg),
 			add_error_report(Context, [words(Msg)], !Errors),
Index: follow_code.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/follow_code.m,v
retrieving revision 1.69
diff -u -b -r1.69 follow_code.m
Index: foreign.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/foreign.m,v
retrieving revision 1.38
diff -u -b -r1.38 foreign.m
--- foreign.m	9 Jun 2004 07:56:10 -0000	1.38
+++ foreign.m	12 Jun 2004 16:48:13 -0000
@@ -28,8 +28,6 @@
 
 :- type foreign_decl_info ==	list(foreign_decl_code).
 		% in reverse order
-:- type foreign_import_module_info == list(foreign_import_module).
-		% in reverse order
 :- type foreign_body_info   ==	list(foreign_body_code).
 		% in reverse order
 
@@ -41,13 +39,6 @@
 			prog_context
 		).
 
-:- type foreign_import_module
-	--->	foreign_import_module(
-			foreign_language,
-			module_name,
-			prog_context
-		).
-
 :- type foreign_body_code
 	--->	foreign_body_code(
 			foreign_language,
@@ -197,21 +188,12 @@
 :- func foreign__prefer_foreign_language(globals, compilation_target,
 	foreign_language, foreign_language) = bool.
 
-	% A string representation of the foreign language suitable
-	% for use in human-readable error messages
-:- func foreign_language_string(foreign_language) = string.
-
-	% A string representation of the foreign language suitable
-	% for use in machine-readable name mangling.
-:- func simple_foreign_language_string(foreign_language) = string.
-
 	% Sub-type of foreign_language for languages for which
 	% we generate external files for foreign code.
 :- inst lang_gen_ext_file
 	--->	c
 	;	managed_cplusplus
-	;	csharp
-	.
+	;	csharp.
 
 	% The file extension used for this foreign language (including
 	% the dot).
@@ -253,6 +235,7 @@
 :- import_module parse_tree__error_util.
 :- import_module parse_tree__modules.
 :- import_module parse_tree__prog_out.
+:- import_module parse_tree__prog_util.
 
 :- import_module list, map, assoc_list, std_util, string, varset, int, term.
 :- import_module require.
@@ -625,18 +608,6 @@
 	),
 
 	create_pragma_import_c_code(PragmaVars, ModuleInfo, C_Code3, C_Code).
-
-foreign_language_string(c) = "C".
-foreign_language_string(managed_cplusplus) = "Managed C++".
-foreign_language_string(csharp) = "C#".
-foreign_language_string(il) = "IL".
-foreign_language_string(java) = "Java".
-
-simple_foreign_language_string(c) = "c".
-simple_foreign_language_string(managed_cplusplus) = "cpp". % XXX mcpp is better
-simple_foreign_language_string(csharp) = "csharp".
-simple_foreign_language_string(il) = "il".
-simple_foreign_language_string(java) = "java".
 
 foreign_language_file_extension(c) = ".c".
 foreign_language_file_extension(managed_cplusplus) = ".cpp".
Index: frameopt.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/frameopt.m,v
retrieving revision 1.86
diff -u -b -r1.86 frameopt.m
Index: gcc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/gcc.m,v
retrieving revision 1.29
diff -u -b -r1.29 gcc.m
Index: global_data.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/global_data.m,v
retrieving revision 1.5
diff -u -b -r1.5 global_data.m
Index: globals.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/globals.m,v
retrieving revision 1.60
diff -u -b -r1.60 globals.m
--- globals.m	14 May 2004 08:40:22 -0000	1.60
+++ globals.m	12 Jun 2004 16:48:48 -0000
@@ -43,8 +43,15 @@
  	;	csharp
  	;	managed_cplusplus
  	;	java
- 	;	il
-	.
+ 	;	il.
+
+	% A string representation of the foreign language suitable
+	% for use in human-readable error messages
+:- func foreign_language_string(foreign_language) = string.
+
+	% A string representation of the foreign language suitable
+	% for use in machine-readable name mangling.
+:- func simple_foreign_language_string(foreign_language) = string.
 
 	% The GC method specifies how we do garbage collection.
 	% The last four alternatives are for the C and asm back-ends;
@@ -272,6 +279,18 @@
 convert_termination_norm("num-data-elems", num_data_elems).
 convert_termination_norm("size-data-elems", size_data_elems).
 
+foreign_language_string(c) = "C".
+foreign_language_string(managed_cplusplus) = "Managed C++".
+foreign_language_string(csharp) = "C#".
+foreign_language_string(il) = "IL".
+foreign_language_string(java) = "Java".
+
+simple_foreign_language_string(c) = "c".
+simple_foreign_language_string(managed_cplusplus) = "cpp". % XXX mcpp is better
+simple_foreign_language_string(csharp) = "csharp".
+simple_foreign_language_string(il) = "il".
+simple_foreign_language_string(java) = "java".
+
 gc_is_conservative(boehm) = yes.
 gc_is_conservative(mps) = yes.
 gc_is_conservative(none) = no.
Index: goal_form.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/goal_form.m,v
retrieving revision 1.9
diff -u -b -r1.9 goal_form.m
Index: goal_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/goal_util.m,v
retrieving revision 1.94
diff -u -b -r1.94 goal_util.m
--- goal_util.m	7 Jun 2004 09:06:39 -0000	1.94
+++ goal_util.m	12 Jun 2004 15:02:58 -0000
@@ -14,12 +14,10 @@
 :- module hlds__goal_util.
 :- interface.
 
-:- import_module hlds__hlds_data.
 :- import_module hlds__hlds_goal.
 :- import_module hlds__hlds_module.
 :- import_module hlds__hlds_pred.
 :- import_module hlds__instmap.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__prog_data.
 
 :- import_module assoc_list, bool, list, set, map, term, std_util.
@@ -253,8 +251,9 @@
 :- import_module hlds__goal_form.
 :- import_module hlds__hlds_data.
 :- import_module hlds__hlds_llds.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__prog_data.
+:- import_module parse_tree__prog_mode.
+:- import_module parse_tree__prog_util.
 
 :- import_module int, string, require, varset.
 
Index: handle_options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.205
diff -u -b -r1.205 handle_options.m
Index: higher_order.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/higher_order.m,v
retrieving revision 1.118
diff -u -b -r1.118 higher_order.m
--- higher_order.m	7 Jun 2004 09:06:40 -0000	1.118
+++ higher_order.m	12 Jun 2004 16:08:53 -0000
@@ -51,9 +51,9 @@
 :- import_module hlds__special_pred.
 :- import_module libs__globals.
 :- import_module libs__options.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__mercury_to_mercury.
 :- import_module parse_tree__prog_data.
+:- import_module parse_tree__prog_mode.
 :- import_module parse_tree__prog_out.
 :- import_module parse_tree__prog_util.
 :- import_module transform_hlds__inlining.
@@ -510,9 +510,7 @@
 traverse_goal_2(Goal0, Goal) -->
 	{ Goal0 = GoalExpr0 - _ },
 	{ GoalExpr0 = unify(_, _, _, Unify0, _) },
-	(
-		{ Unify0 = construct(_, pred_const(_, _, _), _, _, _, _, _) }
-	->
+	( { Unify0 = construct(_, pred_const(_, _), _, _, _, _, _) } ->
 		maybe_specialize_pred_const(Goal0, Goal)
 	;
 		{ Goal = Goal0 }
@@ -714,7 +712,7 @@
 is_interesting_cons_id(Params, int_const(_)) = Params ^ user_type_spec.
 is_interesting_cons_id(_Params, string_const(_)) = no.
 is_interesting_cons_id(_Params, float_const(_)) = no.
-is_interesting_cons_id(Params, pred_const(_, _, _)) =
+is_interesting_cons_id(Params, pred_const(_, _)) =
 	Params ^ optimize_higher_order.
 is_interesting_cons_id(Params, type_ctor_info_const(_, _, _)) =
 	Params ^ user_type_spec.
@@ -724,7 +722,7 @@
 	Params ^ user_type_spec.
 is_interesting_cons_id(Params, typeclass_info_cell_constructor) =
 	Params ^ user_type_spec.
-is_interesting_cons_id(_Params, tabling_pointer_const(_, _)) = no.
+is_interesting_cons_id(_Params, tabling_pointer_const(_)) = no.
 is_interesting_cons_id(_Params, deep_profiling_proc_layout(_)) = no.
 is_interesting_cons_id(_Params, table_io_decl(_)) = no.
 
@@ -745,11 +743,11 @@
 		map__search(Info0 ^ pred_vars, PredVar,
 			constant(ConsId, CurriedArgs)),
 		(
-			ConsId = pred_const(PredId0, ProcId0, _),
+			ConsId = pred_const(ShroudedPredProcId, _),
 			MaybeMethod = no
 		->
-			PredId = PredId0,
-			ProcId = ProcId0,
+			proc(PredId, ProcId) =
+				unshroud_pred_proc_id(ShroudedPredProcId),
 			list__append(CurriedArgs, Args, AllArgs)
 		;
 			% A typeclass_info variable should consist of
@@ -1092,8 +1090,10 @@
 		{ Goal0 = unify(_, _, UniMode, Unify0, Context) },
 		{ Unify0 = construct(LVar, ConsId0, Args0, _,
 			HowToConstruct, CellIsUnique, no) },
-		{ ConsId0 = pred_const(PredId, ProcId, EvalMethod) },
-		{ map__contains(NewPreds, proc(PredId, ProcId)) },
+		{ ConsId0 = pred_const(ShroudedPredProcId, EvalMethod) },
+		{ PredProcId = unshroud_pred_proc_id(ShroudedPredProcId) },
+		{ proc(PredId, ProcId) = PredProcId },
+		{ map__contains(NewPreds, PredProcId) },
 		{ proc_info_vartypes(ProcInfo0, VarTypes0) },
 		{ map__lookup(VarTypes0, LVar, LVarType) },
 		{ type_is_higher_order(LVarType, _, _, _, ArgTypes) }
@@ -1157,7 +1157,10 @@
 				ProcInfo2, ProcInfo) },
 			^ proc_info := ProcInfo,
 
-			{ NewConsId = pred_const(NewPredId, NewProcId,
+			{ NewPredProcId = proc(NewPredId, NewProcId) },
+			{ NewShroudedPredProcId =
+				shroud_pred_proc_id(NewPredProcId) },
+			{ NewConsId = pred_const(NewShroudedPredProcId,
 				EvalMethod) },
 			{ Unify = construct(LVar, NewConsId, NewArgs, UniModes,
 				HowToConstruct, CellIsUnique, no) },
@@ -1327,7 +1330,7 @@
 		% extract fields from typeclass_infos).
 		ConsId \= int_const(_),
 
-		( ConsId = pred_const(_, _, _) ->
+		( ConsId = pred_const(_, _) ->
 			% If we don't have clauses for the callee, we can't
 			% specialize any higher-order arguments. We may be
 			% able to do user guided type specialization.
@@ -1341,7 +1344,9 @@
 		% Find any known higher-order arguments
 		% in the list of curried arguments.
 		map__apply_to_list(CurriedArgs, VarTypes, CurriedArgTypes),
-		( ConsId = pred_const(PredId, _, _) ->
+		( ConsId = pred_const(ShroudedPredProcId, _) ->
+			proc(PredId, _) =
+				unshroud_pred_proc_id(ShroudedPredProcId),
 			module_info_pred_info(ModuleInfo, PredId, PredInfo),
 			pred_info_arg_types(PredInfo, CurriedCalleeArgTypes)
 		;
@@ -1508,7 +1513,7 @@
 			;
 				HigherOrder = yes,
 				list__member(HOArg, HigherOrderArgs),
-				HOArg = higher_order_arg(pred_const(_, _, _),
+				HOArg = higher_order_arg(pred_const(_, _),
 					_, _, _, _, _, _)
 			;
 				TypeSpec = yes
@@ -1710,7 +1715,7 @@
 	\+ (
 		list__member(RequestArg, RequestArgs),
 		RequestArg = higher_order_arg(RequestConsId, _, _, _, _, _, _),
-		RequestConsId = pred_const(_, _, _)
+		RequestConsId = pred_const(_, _)
 	).
 higher_order_args_match([RequestArg | Args1], [VersionArg | Args2],
 		Args, PartialMatch) :-
@@ -1742,7 +1747,7 @@
 
 		% All the higher-order arguments must be present in the
 		% version otherwise we should create a new one.
-		ConsId1 \= pred_const(_, _, _),
+		ConsId1 \= pred_const(_, _),
 		PartialMatch = yes,
 		higher_order_args_match(Args1, [VersionArg | Args2], Args, _)
 	).
@@ -2590,7 +2595,9 @@
 	;
 		[]
 	),
-	( { ConsId = pred_const(PredId, _ProcId, _) } ->
+	( { ConsId = pred_const(ShroudedPredProcId, _) } ->
+		{ proc(PredId, _) =
+			unshroud_pred_proc_id(ShroudedPredProcId) },
 		{ module_info_pred_info(ModuleInfo, PredId, PredInfo) },
 		{ Name = pred_info_name(PredInfo) },
 		{ Arity = pred_info_arity(PredInfo) },
@@ -2946,8 +2953,10 @@
 		CurriedArgs, CurriedArgTypes, CurriedHOArgs, IsConst),
 
 	list__index1_det(HeadVars0, Index, LVar),
-	( ConsId = pred_const(PredId, ProcId, _) ->
+	( ConsId = pred_const(ShroudedPredProcId, _) ->
 		% Add the curried arguments to the procedure's argument list.
+		proc(PredId, ProcId) =
+			unshroud_pred_proc_id(ShroudedPredProcId),
 		module_info_pred_proc_info(ModuleInfo, PredId, ProcId,
 			CalledPredInfo, CalledProcInfo),
 		PredOrFunc = pred_info_is_pred_or_func(CalledPredInfo),
@@ -3111,7 +3120,6 @@
 		;
 			error("remove_const_higher_order_args")
 		)
-			
 	;
 		Args = [Arg | Args0]
 	).
Index: hlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds.m,v
retrieving revision 1.213
diff -u -b -r1.213 hlds.m
--- hlds.m	23 Mar 2004 10:52:03 -0000	1.213
+++ hlds.m	12 Jun 2004 17:07:23 -0000
@@ -48,7 +48,7 @@
 :- import_module libs.
 :- import_module check_hlds.		% needed for unify_proc__unify_proc_id,
 					% etc.
-:- import_module transform_hlds.	% needed for mmc_analysis, term_util
+:- import_module transform_hlds.	% needed for term_util
 
 :- end_module hlds.
 
Index: hlds_code_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_code_util.m,v
retrieving revision 1.11
diff -u -b -r1.11 hlds_code_util.m
--- hlds_code_util.m	19 May 2004 03:59:11 -0000	1.11
+++ hlds_code_util.m	12 Jun 2004 10:05:03 -0000
@@ -40,6 +40,7 @@
 :- implementation.
 
 :- import_module check_hlds__type_util.
+:- import_module hlds__hlds_pred.
 :- import_module libs__globals.
 :- import_module libs__options.
 :- import_module parse_tree__prog_io.
@@ -58,21 +59,27 @@
 
 %-----------------------------------------------------------------------------%
 
-cons_id_to_tag(int_const(X), _, _) = int_constant(X).
-cons_id_to_tag(float_const(X), _, _) = float_constant(X).
-cons_id_to_tag(string_const(X), _, _) = string_constant(X).
-cons_id_to_tag(pred_const(P,M,E), _, _) = pred_closure_tag(P,M,E).
+cons_id_to_tag(int_const(I), _, _) = int_constant(I).
+cons_id_to_tag(float_const(F), _, _) = float_constant(F).
+cons_id_to_tag(string_const(S), _, _) = string_constant(S).
+cons_id_to_tag(pred_const(ShroudedPredProcId, EvalMethod), _, _) =
+		pred_closure_tag(PredId, ProcId, EvalMethod) :-
+	proc(PredId, ProcId) = unshroud_pred_proc_id(ShroudedPredProcId).
 cons_id_to_tag(type_ctor_info_const(M,T,A), _, _) =
 		type_ctor_info_constant(M,T,A).
 cons_id_to_tag(base_typeclass_info_const(M,C,_,N), _, _) =
 		base_typeclass_info_constant(M,C,N).
 cons_id_to_tag(type_info_cell_constructor(_), _, _) = unshared_tag(0).
 cons_id_to_tag(typeclass_info_cell_constructor, _, _) = unshared_tag(0).
-cons_id_to_tag(tabling_pointer_const(PredId,ProcId), _, _) =
-		tabling_pointer_constant(PredId,ProcId).
-cons_id_to_tag(deep_profiling_proc_layout(PPId), _, _) =
-		deep_profiling_proc_layout_tag(PPId).
-cons_id_to_tag(table_io_decl(PPId), _, _) = table_io_decl_tag(PPId).
+cons_id_to_tag(tabling_pointer_const(ShroudedPredProcId), _, _) =
+		tabling_pointer_constant(PredId, ProcId) :-
+	proc(PredId, ProcId) = unshroud_pred_proc_id(ShroudedPredProcId).
+cons_id_to_tag(deep_profiling_proc_layout(ShroudedPredProcId), _, _) =
+		deep_profiling_proc_layout_tag(PredId, ProcId) :-
+	proc(PredId, ProcId) = unshroud_pred_proc_id(ShroudedPredProcId).
+cons_id_to_tag(table_io_decl(ShroudedPredProcId), _, _) =
+		table_io_decl_tag(PredId, ProcId) :-
+	proc(PredId, ProcId) = unshroud_pred_proc_id(ShroudedPredProcId).
 cons_id_to_tag(cons(Name, Arity), Type, ModuleInfo) = Tag :-
 	(
 			% handle the `character' type specially
Index: hlds_data.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_data.m,v
retrieving revision 1.86
diff -u -b -r1.86 hlds_data.m
--- hlds_data.m	19 May 2004 03:59:11 -0000	1.86
+++ hlds_data.m	12 Jun 2004 13:52:26 -0000
@@ -14,10 +14,9 @@
 :- interface.
 
 :- import_module hlds__hlds_pred.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__prog_data.
 
-:- import_module bool, list, map, std_util, term.
+:- import_module bool, list, map, std_util.
 
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
@@ -28,44 +27,6 @@
 
 :- type cons_table	==	map(cons_id, list(hlds_cons_defn)).
 
-:- type cons_id
-	--->	cons(sym_name, arity)	% name, arity
-		% Tuples have cons_id
-		% `cons(unqualified("{}"), Arity)'.
-
-	;	int_const(int)
-	;	string_const(string)
-	;	float_const(float)
-	;	pred_const(pred_id, proc_id, lambda_eval_method)
-		% Note that a pred_const represents a closure,
-		% not just a code address.
-	;	type_ctor_info_const(module_name, string, int)
-		% module name, type name, type arity
-	;	base_typeclass_info_const(module_name, class_id, int, string)
-		% module name of instance declaration
-		% (not filled in so that link errors result
-		% from overlapping instances),
-		% class name and arity,
-		% class instance, a string encoding the type
-		% names and arities of the arguments to the
-		% instance declaration
-	;	type_info_cell_constructor(type_ctor)
-		% module name, type name, type arity
-	;	typeclass_info_cell_constructor
-	;	tabling_pointer_const(pred_id, proc_id)
-		% The address of the static variable
-		% that points to the table that implements
-		% memoization, loop checking or the minimal
-		% model semantics for the given procedure.
-	;	deep_profiling_proc_layout(rtti_proc_label)
-		% The Proc_Layout structure of a procedure. Its proc_static
-		% field is used by deep profiling, as documented in the deep
-		% profiling paper.
-	;	table_io_decl(rtti_proc_label).
-		% The address of a structure that describes
-		% the layout of the answer block used by
-		% I/O tabling for declarative debugging.
-
 	% A cons_defn is the definition of a constructor (i.e. a constant
 	% or a functor) for a particular type.
 
@@ -125,134 +86,6 @@
 	;	set.
 
 %-----------------------------------------------------------------------------%
-
-	% Various predicates for accessing the cons_id type.
-
-	% Given a cons_id and a list of argument terms, convert it into a
-	% term. Fails if the cons_id is a pred_const, or type_ctor_info_const.
-
-:- pred cons_id_and_args_to_term(cons_id::in, list(term(T))::in, term(T)::out)
-	is semidet.
-
-	% Get the arity of a cons_id, aborting on pred_const and
-	% type_ctor_info_const.
-
-:- func cons_id_arity(cons_id) = arity.
-
-	% Get the arity of a cons_id. Return a `no' on those cons_ids
-	% where cons_id_arity/2 would normally abort.
-
-:- func cons_id_maybe_arity(cons_id) = maybe(arity).
-
-	% The reverse conversion - make a cons_id for a functor.
-	% Given a const and an arity for the functor, create a cons_id.
-
-:- func make_functor_cons_id(const, arity) = cons_id.
-
-	% Another way of making a cons_id from a functor.
-	% Given the name, argument types, and type_ctor of a functor,
-	% create a cons_id for that functor.
-
-:- func make_cons_id(sym_name, list(constructor_arg), type_ctor) = cons_id.
-
-	% Another way of making a cons_id from a functor.
-	% Given the name, argument types, and type_ctor of a functor,
-	% create a cons_id for that functor.
-	%
-	% Differs from make_cons_id in that (a) it requires the sym_name
-	% to be already module qualified, which means that it does not
-	% need the module qualification of the type, (b) it can compute the
-	% arity from any list of the right length.
-
-:- func make_cons_id_from_qualified_sym_name(sym_name, list(_)) = cons_id.
-
-%-----------------------------------------------------------------------------%
-
-:- implementation.
-
-:- import_module parse_tree__prog_util.
-
-:- import_module string, require, varset.
-
-cons_id_and_args_to_term(int_const(Int), [], Term) :-
-	term__context_init(Context),
-	Term = term__functor(term__integer(Int), [], Context).
-cons_id_and_args_to_term(float_const(Float), [], Term) :-
-	term__context_init(Context),
-	Term = term__functor(term__float(Float), [], Context).
-cons_id_and_args_to_term(string_const(String), [], Term) :-
-	term__context_init(Context),
-	Term = term__functor(term__string(String), [], Context).
-cons_id_and_args_to_term(cons(SymName, _Arity), Args, Term) :-
-	construct_qualified_term(SymName, Args, Term).
-
-cons_id_arity(cons(_, Arity)) = Arity.
-cons_id_arity(int_const(_)) = 0.
-cons_id_arity(string_const(_)) = 0.
-cons_id_arity(float_const(_)) = 0.
-cons_id_arity(pred_const(_, _, _)) =
-	func_error("cons_id_arity: can't get arity of pred_const").
-cons_id_arity(type_ctor_info_const(_, _, _)) =
-	func_error("cons_id_arity: can't get arity of type_ctor_info_const").
-cons_id_arity(base_typeclass_info_const(_, _, _, _)) =
-	func_error("cons_id_arity: " ++
-		"can't get arity of base_typeclass_info_const").
-cons_id_arity(type_info_cell_constructor(_)) =
-	func_error("cons_id_arity: " ++
-		"can't get arity of type_info_cell_constructor").
-cons_id_arity(typeclass_info_cell_constructor) =
-	func_error("cons_id_arity: " ++
-		"can't get arity of typeclass_info_cell_constructor").
-cons_id_arity(tabling_pointer_const(_, _)) =
-	func_error("cons_id_arity: can't get arity of tabling_pointer_const").
-cons_id_arity(deep_profiling_proc_layout(_)) =
-	func_error("cons_id_arity: " ++
-		"can't get arity of deep_profiling_proc_layout").
-cons_id_arity(table_io_decl(_)) =
-	func_error("cons_id_arity: can't get arity of table_io_decl").
-
-cons_id_maybe_arity(cons(_, Arity)) = yes(Arity).
-cons_id_maybe_arity(int_const(_)) = yes(0).
-cons_id_maybe_arity(string_const(_)) = yes(0).
-cons_id_maybe_arity(float_const(_)) = yes(0).
-cons_id_maybe_arity(pred_const(_, _, _)) = no.
-cons_id_maybe_arity(type_ctor_info_const(_, _, _)) = no.
-cons_id_maybe_arity(base_typeclass_info_const(_, _, _, _)) = no.
-cons_id_maybe_arity(type_info_cell_constructor(_)) = no.
-cons_id_maybe_arity(typeclass_info_cell_constructor) = no.
-cons_id_maybe_arity(tabling_pointer_const(_, _)) = no.
-cons_id_maybe_arity(deep_profiling_proc_layout(_)) = no.
-cons_id_maybe_arity(table_io_decl(_)) = no.
-
-make_functor_cons_id(term__atom(Name), Arity) = cons(unqualified(Name), Arity).
-make_functor_cons_id(term__integer(Int), _) = int_const(Int).
-make_functor_cons_id(term__string(String), _) = string_const(String).
-make_functor_cons_id(term__float(Float), _) = float_const(Float).
-
-make_cons_id(SymName0, Args, TypeCtor) = cons(SymName, Arity) :-
-	% Use the module qualifier on the SymName, if there is one,
-	% otherwise use the module qualifier on the Type, if there is one,
-	% otherwise leave it unqualified.
-	% XXX is that the right thing to do?
-	(
-		SymName0 = qualified(_, _),
-		SymName = SymName0
-	;
-		SymName0 = unqualified(ConsName),
-		(
-			TypeCtor = unqualified(_) - _,
-			SymName = SymName0
-		;
-			TypeCtor = qualified(TypeModule, _) - _,
-			SymName = qualified(TypeModule, ConsName)
-		)
-	),
-	list__length(Args, Arity).
-
-make_cons_id_from_qualified_sym_name(SymName, Args) = cons(SymName, Arity) :-
-	list__length(Args, Arity).
-
-%-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
 
 :- interface.
@@ -400,10 +233,10 @@
 			% represented as global data. The word just contains
 			% the address of the tabling pointer of the
 			% specified procedure.
-	;	deep_profiling_proc_layout_tag(rtti_proc_label)
+	;	deep_profiling_proc_layout_tag(pred_id, proc_id)
 			% This is for constants representing procedure
 			% descriptions for deep profiling.
-	;	table_io_decl_tag(rtti_proc_label)
+	;	table_io_decl_tag(pred_id, proc_id)
 			% This is for constants representing the structure
 			% that allows us to decode the contents of the memory
 			% block containing the headvars of I/O primitives.
@@ -510,8 +343,8 @@
 get_primary_tag(type_ctor_info_constant(_, _, _)) = no.
 get_primary_tag(base_typeclass_info_constant(_, _, _)) = no.
 get_primary_tag(tabling_pointer_constant(_, _)) = no.
-get_primary_tag(deep_profiling_proc_layout_tag(_)) = no.
-get_primary_tag(table_io_decl_tag(_)) = no.
+get_primary_tag(deep_profiling_proc_layout_tag(_, _)) = no.
+get_primary_tag(table_io_decl_tag(_, _)) = no.
 get_primary_tag(single_functor) = yes(0).
 get_primary_tag(unshared_tag(PrimaryTag)) = yes(PrimaryTag).
 get_primary_tag(shared_remote_tag(PrimaryTag, _SecondaryTag)) =
@@ -529,8 +362,8 @@
 get_secondary_tag(type_ctor_info_constant(_, _, _)) = no.
 get_secondary_tag(base_typeclass_info_constant(_, _, _)) = no.
 get_secondary_tag(tabling_pointer_constant(_, _)) = no.
-get_secondary_tag(deep_profiling_proc_layout_tag(_)) = no.
-get_secondary_tag(table_io_decl_tag(_)) = no.
+get_secondary_tag(deep_profiling_proc_layout_tag(_, _)) = no.
+get_secondary_tag(table_io_decl_tag(_, _)) = no.
 get_secondary_tag(single_functor) = no.
 get_secondary_tag(unshared_tag(_)) = no.
 get_secondary_tag(shared_remote_tag(_PrimaryTag, SecondaryTag)) =
@@ -617,9 +450,6 @@
 
 	% The symbol table for insts.
 
-:- type inst_id		==	pair(sym_name, arity).
-				% name, arity.
-
 :- type inst_table.
 
 :- type user_inst_table.
@@ -810,9 +640,6 @@
 
 	% The symbol table for modes.
 
-:- type mode_id		==	pair(sym_name, arity).
-				% name, arity
-
 :- type mode_table.
 :- type mode_defns	 ==	map(mode_id, hlds_mode_defn).
 
@@ -948,8 +775,6 @@
 :- interface.
 
 :- type class_table == map(class_id, hlds_class_defn).
-
-:- type class_id 	--->	class_id(sym_name, arity).
 
 	% Information about a single `typeclass' declaration
 :- type hlds_class_defn --->
Index: hlds_error_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_error_util.m,v
retrieving revision 1.3
diff -u -b -r1.3 hlds_error_util.m
--- hlds_error_util.m	14 May 2004 08:40:23 -0000	1.3
+++ hlds_error_util.m	12 Jun 2004 15:03:38 -0000
@@ -59,6 +59,7 @@
 
 :- import_module check_hlds__mode_util.
 :- import_module parse_tree__mercury_to_mercury.
+:- import_module parse_tree__prog_mode.
 :- import_module parse_tree__prog_out.
 :- import_module parse_tree__prog_util.
 
Index: hlds_goal.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_goal.m,v
retrieving revision 1.116
diff -u -b -r1.116 hlds_goal.m
--- hlds_goal.m	7 Jun 2004 09:06:41 -0000	1.116
+++ hlds_goal.m	12 Jun 2004 15:04:47 -0000
@@ -16,7 +16,6 @@
 :- import_module hlds__hlds_llds.
 :- import_module hlds__hlds_pred.
 :- import_module hlds__instmap.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__prog_data.
 
 :- import_module bool, char, list, set, std_util.
@@ -1099,10 +1098,10 @@
 :- import_module check_hlds__mode_util.
 :- import_module check_hlds__purity.
 :- import_module check_hlds__type_util.
+:- import_module parse_tree__prog_mode.
 :- import_module parse_tree__prog_util.
-:- import_module assoc_list, require, string, term, varset.
 
-:- import_module map, require, string, term, varset.
+:- import_module assoc_list, map, require, string, term, varset.
 
 %-----------------------------------------------------------------------------%
 
Index: hlds_llds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_llds.m,v
retrieving revision 1.5
diff -u -b -r1.5 hlds_llds.m
Index: hlds_module.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_module.m,v
retrieving revision 1.100
diff -u -b -r1.100 hlds_module.m
--- hlds_module.m	9 Jun 2004 07:56:10 -0000	1.100
+++ hlds_module.m	12 Jun 2004 17:24:54 -0000
@@ -39,10 +39,10 @@
 
 :- import_module check_hlds__typecheck.
 :- import_module hlds__hlds_out.
+:- import_module transform_hlds__mmc_analysis.
 :- import_module parse_tree__modules.
 :- import_module parse_tree__prog_out.
 :- import_module parse_tree__prog_util.
-:- import_module transform_hlds__mmc_analysis.
 
 :- import_module bool, require, int, string.
 
@@ -1942,7 +1942,7 @@
                 % Undefined/invalid pred or func.
 		% the type-checker should ensure that this never happens
 		list__length(ArgTypes, Arity),
-		PredOrFuncStr = hlds_out__pred_or_func_to_str(PredOrFunc),
+		PredOrFuncStr = pred_or_func_to_str(PredOrFunc),
 		prog_out__sym_name_to_string(SymName, Name2),
 		string__int_to_string(Arity, ArityString),
 		string__append_list(["get_pred_id_and_proc_id: ", 
@@ -1962,7 +1962,7 @@
 		Name = pred_info_name(PredInfo),
 		PredOrFunc = pred_info_is_pred_or_func(PredInfo),
 		Arity = pred_info_arity(PredInfo),
-		PredOrFuncStr = hlds_out__pred_or_func_to_str(PredOrFunc),
+		PredOrFuncStr = pred_or_func_to_str(PredOrFunc),
 		string__int_to_string(Arity, ArityString),
 		( ProcIds = [] ->
 			string__append_list([
Index: hlds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_out.m,v
retrieving revision 1.333
diff -u -b -r1.333 hlds_out.m
--- hlds_out.m	7 Jun 2004 09:06:42 -0000	1.333
+++ hlds_out.m	12 Jun 2004 16:56:24 -0000
@@ -34,7 +34,6 @@
 
 % Parse tree modules
 :- import_module parse_tree__error_util.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__prog_data.
 % HLDS modules
 :- import_module hlds__hlds_data.
@@ -99,15 +98,6 @@
 	io::di, io::uo) is det.
 :- func hlds_out__call_arg_id_to_string(call_id, int, pred_markers) = string.
 
-	% Print "predicate" or "function" depending on the given value.
-:- pred hlds_out__write_pred_or_func(pred_or_func::in, io::di, io::uo) is det.
-
-	% Return "predicate" or "function" depending on the given value.
-:- func hlds_out__pred_or_func_to_full_str(pred_or_func) = string.
-
-	% Return "pred" or "func" depending on the given value.
-:- func hlds_out__pred_or_func_to_str(pred_or_func) = string.
-
 	% hlds_out__write_unify_context/5 writes out a message such as
 	%	foo.m:123:   in argument 3 of functor `foo/5':
 	%	foo.m:123:   in unification of `X' and `blah':
@@ -243,12 +233,33 @@
 :- func inst_to_term(inst) = prog_term.
 
 %-----------------------------------------------------------------------------%
+
+:- pred mercury_output_uni_mode(uni_mode::in, inst_varset::in,
+	io::di, io::uo) is det.
+
+:- func mercury_uni_mode_to_string(uni_mode, inst_varset) = string.
+
+:- pred mercury_output_uni_mode_list(list(uni_mode)::in, inst_varset::in,
+	io::di, io::uo) is det.
+
+:- func mercury_uni_mode_list_to_string(list(uni_mode), inst_varset) = string.
+
+	% Output an inst in a format where all compiler-defined insts
+	% have been expanded out; recursive insts have their self-referential
+	% parts printed out as elipses ("...").
+	% (These routines are used for outputting insts in mode errors.)
+
+:- pred mercury_output_expanded_inst((inst)::in, inst_varset::in,
+	module_info::in, io::di, io::uo) is det.
+:- func mercury_expanded_inst_to_string(inst, inst_varset, module_info)
+	= string.
+
+%-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
 
 :- implementation.
 
 % Parse tree modules.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__mercury_to_mercury.
 :- import_module parse_tree__prog_out.
 :- import_module parse_tree__prog_util.
@@ -256,19 +267,13 @@
 % HLDS modules.
 :- import_module check_hlds__check_typeclass.
 :- import_module check_hlds__purity.
+:- import_module check_hlds__mode_util.
 :- import_module check_hlds__type_util.
 :- import_module hlds__hlds_llds.
 :- import_module hlds__instmap.
 :- import_module hlds__special_pred.
 
-% RL back-end modules (XXX should avoid using those here).
-:- import_module aditi_backend.
-:- import_module aditi_backend__rl.
-
 % Misc
-:- import_module backend_libs.
-:- import_module backend_libs__foreign.
-:- import_module backend_libs__rtti.
 :- import_module libs__globals.
 :- import_module libs__options.
 
@@ -313,9 +318,10 @@
 	term_io__quoted_string(String).
 hlds_out__cons_id_to_string(float_const(Float)) =
 	float_to_string(Float).
-hlds_out__cons_id_to_string(pred_const(PredId, ProcId, _)) =
-	"<pred " ++ int_to_string(pred_id_to_int(PredId)) ++
-	" proc " ++ int_to_string(proc_id_to_int(ProcId)) ++ ">".
+hlds_out__cons_id_to_string(
+		pred_const(shrouded_pred_proc_id(PredId, ProcId), _)) =
+	"<pred " ++ int_to_string(PredId) ++
+	" proc " ++ int_to_string(ProcId) ++ ">".
 hlds_out__cons_id_to_string(type_ctor_info_const(Module, Ctor, Arity)) =
 	"<type_ctor_info " ++ sym_name_to_string(Module) ++ "." ++
 	Ctor ++ "/" ++ int_to_string(Arity) ++ ">".
@@ -325,12 +331,18 @@
 	"<type_info_cell_constructor>".
 hlds_out__cons_id_to_string(typeclass_info_cell_constructor) =
 	"<typeclass_info_cell_constructor>".
-hlds_out__cons_id_to_string(tabling_pointer_const(PredId, ProcId)) =
-	"<tabling_pointer " ++ int_to_string(pred_id_to_int(PredId)) ++
-	", " ++ int_to_string(proc_id_to_int(ProcId)) ++ ">".
-hlds_out__cons_id_to_string(deep_profiling_proc_layout(_)) =
-	"<deep_profiling_proc_layout>".
-hlds_out__cons_id_to_string(table_io_decl(_)) = "<table_io_decl>".
+hlds_out__cons_id_to_string(
+		tabling_pointer_const(shrouded_pred_proc_id(PredId, ProcId))) =
+	"<tabling_pointer " ++ int_to_string(PredId) ++
+	", " ++ int_to_string(ProcId) ++ ">".
+hlds_out__cons_id_to_string(deep_profiling_proc_layout(
+		shrouded_pred_proc_id(PredId, ProcId))) =
+	"<deep_profiling_proc_layout " ++ int_to_string(PredId) ++
+	", " ++ int_to_string(ProcId) ++ ">".
+hlds_out__cons_id_to_string(table_io_decl(
+		shrouded_pred_proc_id(PredId, ProcId))) =
+	"<table_io_decl " ++ int_to_string(PredId) ++
+	", " ++ int_to_string(ProcId) ++ ">".
 
 	% The code of this predicate duplicates the functionality of
 	% hlds_error_util__describe_one_pred_name. Changes here should be made
@@ -591,18 +603,6 @@
 	% at the front of the argument list.
 	Str = "argument " ++ int_to_string(ArgNum + 1).
 
-hlds_out__write_pred_or_func(predicate, !IO) :-
-	io__write_string("predicate", !IO).
-
-hlds_out__write_pred_or_func(function, !IO) :-
-	io__write_string("function", !IO).
-
-hlds_out__pred_or_func_to_full_str(predicate) = "predicate".
-hlds_out__pred_or_func_to_full_str(function) = "function".
-
-hlds_out__pred_or_func_to_str(predicate) = "pred".
-hlds_out__pred_or_func_to_str(function) = "func".
-
 %-----------------------------------------------------------------------------%
 
 hlds_out__write_unify_context(UnifyContext, Context, !IO) :-
@@ -928,7 +928,7 @@
 		pred_id_to_int(PredId, PredInt),
 		io__write_int(PredInt, !IO),
 		io__write_string(", category: ", !IO),
-		hlds_out__write_pred_or_func(PredOrFunc, !IO),
+		write_pred_or_func(PredOrFunc, !IO),
 		io__write_string(", status: ", !IO),
 		hlds_out__write_import_status(ImportStatus, !IO),
 		io__write_string("\n", !IO),
@@ -2220,7 +2220,7 @@
 	io__write_string(UpdateName, !IO),
 	io__write_string("(", !IO),
 	CallId = PredOrFunc - _,
-	PredOrFuncStr = hlds_out__pred_or_func_to_str(PredOrFunc),
+	PredOrFuncStr = pred_or_func_to_str(PredOrFunc),
 	io__write_string(PredOrFuncStr, !IO),
 	io__write_string(" ", !IO),
 	hlds_out__simple_call_id_to_sym_name_and_arity(CallId, SymArity),
@@ -2590,7 +2590,8 @@
 		hlds_out__write_functor(term__string(Str), ArgVars,
 			VarSet, AppendVarNums, !IO)
 	;
-		ConsId = pred_const(PredId, _, _),
+		ConsId = pred_const(ShroudedPredProcId, _),
+		proc(PredId, _) = unshroud_pred_proc_id(ShroudedPredProcId),
 		module_info_pred_info(ModuleInfo, PredId, PredInfo),
 		PredModule = pred_info_module(PredInfo),
 		PredName = pred_info_name(PredInfo),
@@ -2633,7 +2634,9 @@
 			ArgVars, VarSet, AppendVarNums, next_to_graphic_token,
 			!IO)
 	;
-		ConsId = tabling_pointer_const(PredId, ProcId),
+		ConsId = tabling_pointer_const(ShroudedPredProcId),
+		proc(PredId, ProcId) =
+			unshroud_pred_proc_id(ShroudedPredProcId),
 		io__write_string("tabling_pointer_const(", !IO),
 		hlds_out__write_pred_id(ModuleInfo, PredId, !IO),
 		io__write_string(", ", !IO),
@@ -2641,8 +2644,9 @@
 		io__write_int(ProcIdInt, !IO),
 		io__write_string(")", !IO)
 	;
-		ConsId = deep_profiling_proc_layout(RttiProcLabel),
-		rtti__proc_label_pred_proc_id(RttiProcLabel, PredId, ProcId),
+		ConsId = deep_profiling_proc_layout(ShroudedPredProcId),
+		proc(PredId, ProcId) =
+			unshroud_pred_proc_id(ShroudedPredProcId),
 		io__write_string("deep_profiling_proc_layout(", !IO),
 		hlds_out__write_pred_id(ModuleInfo, PredId, !IO),
 		proc_id_to_int(ProcId, ProcIdInt),
@@ -2650,8 +2654,9 @@
 		io__write_int(ProcIdInt, !IO),
 		io__write_string("))", !IO)
 	;
-		ConsId = table_io_decl(RttiProcLabel),
-		rtti__proc_label_pred_proc_id(RttiProcLabel, PredId, ProcId),
+		ConsId = table_io_decl(ShroudedPredProcId),
+		proc(PredId, ProcId) =
+			unshroud_pred_proc_id(ShroudedPredProcId),
 		io__write_string("table_io_decl(", !IO),
 		hlds_out__write_pred_id(ModuleInfo, PredId, !IO),
 		proc_id_to_int(ProcId, ProcIdInt),
@@ -4017,6 +4022,88 @@
 det_to_string(cc_nondet) = "cc_nondet".
 det_to_string(multidet) = "multi".
 det_to_string(nondet) = "nondet".
+
+%-----------------------------------------------------------------------------%
+
+mercury_output_uni_mode_list(UniModes, VarSet) -->
+	mercury_format_uni_mode_list(UniModes, VarSet).
+
+mercury_uni_mode_list_to_string(UniModes, VarSet) = String :-
+	mercury_format_uni_mode_list(UniModes, VarSet, "", String).
+
+:- pred mercury_format_uni_mode_list(list(uni_mode)::in, inst_varset::in,
+	U::di, U::uo) is det <= output(U).
+
+mercury_format_uni_mode_list([], _VarSet) --> [].
+mercury_format_uni_mode_list([Mode | Modes], VarSet) -->
+	mercury_format_uni_mode(Mode, VarSet),
+	( { Modes = [] } ->
+		[]
+	;
+		add_string(", "),
+		mercury_format_uni_mode_list(Modes, VarSet)
+	).
+
+mercury_output_uni_mode(UniMode, VarSet) -->
+	mercury_format_uni_mode(UniMode, VarSet).
+
+mercury_uni_mode_to_string(UniMode, VarSet) = String :-
+	mercury_format_uni_mode(UniMode, VarSet, "", String).
+
+:- pred mercury_format_uni_mode(uni_mode::in, inst_varset::in,
+	U::di, U::uo) is det <= output(U).
+
+mercury_format_uni_mode((InstA1 - InstB1 -> InstA2 - InstB2), VarSet) -->
+	mercury_format_mode((InstA1 -> InstA2), simple_inst_info(VarSet)),
+	add_string(" = "),
+	mercury_format_mode((InstB1 -> InstB2), simple_inst_info(VarSet)).
+
+:- instance inst_info(expanded_inst_info) where [
+	func(instvarset/1) is eii_varset,
+	pred(format_defined_inst/4) is mercury_format_expanded_defined_inst
+].
+
+:- type expanded_inst_info
+	--->	expanded_inst_info(
+			eii_varset	:: inst_varset,
+			eii_module_info	:: module_info,
+			eii_expansions	:: set(inst_name)
+					% the set of already-expanded insts;
+					% further occurrences of these will
+					% be output as "..."
+		).
+
+:- pred mercury_format_expanded_defined_inst(inst_name::in,
+	expanded_inst_info::in, U::di, U::uo) is det <= output(U).
+
+mercury_format_expanded_defined_inst(InstName, ExpandedInstInfo) -->
+	( { set__member(InstName, ExpandedInstInfo ^ eii_expansions) } ->
+		add_string("...")
+	; { InstName = user_inst(_, _) } ->
+		% don't expand user-defined insts, just output them as is
+		% (we do expand any compiler-defined insts that occur
+		% in the arguments of the user-defined inst, however)
+		mercury_format_inst_name(InstName, ExpandedInstInfo)
+        ;
+                { inst_lookup(ExpandedInstInfo ^ eii_module_info, InstName,
+			Inst) },
+                { set__insert(ExpandedInstInfo ^ eii_expansions, InstName,
+			Expansions) },
+		mercury_format_inst(Inst,
+			ExpandedInstInfo ^ eii_expansions := Expansions)
+	).
+
+
+mercury_output_expanded_inst(Inst, VarSet, ModuleInfo, !IO) :-
+	set__init(Expansions),
+	mercury_format_inst(Inst,
+		expanded_inst_info(VarSet, ModuleInfo, Expansions), !IO).
+
+mercury_expanded_inst_to_string(Inst, VarSet, ModuleInfo) = String :-
+	set__init(Expansions),
+	mercury_format_inst(Inst,
+		expanded_inst_info(VarSet, ModuleInfo, Expansions),
+		"", String).
 
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
Index: hlds_pred.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_pred.m,v
retrieving revision 1.146
diff -u -b -r1.146 hlds_pred.m
--- hlds_pred.m	7 Jun 2004 09:06:43 -0000	1.146
+++ hlds_pred.m	12 Jun 2004 15:05:25 -0000
@@ -24,7 +24,7 @@
 :- import_module parse_tree__prog_data.
 :- import_module transform_hlds__term_util.
 
-:- import_module bool, list, assoc_list, set, map, std_util, term, varset.
+:- import_module bool, list, assoc_list, set, map, std_util.
 
 :- implementation.
 
@@ -43,7 +43,7 @@
 :- import_module libs__options.
 
 % Standard library modules.
-:- import_module int, string, require.
+:- import_module int, string, require, varset, term.
 
 %-----------------------------------------------------------------------------%
 
@@ -55,6 +55,7 @@
 
 :- type pred_id.
 :- type proc_id.
+:- type pred_proc_id	--->	proc(pred_id, proc_id).
 
 	% Predicate and procedure ids are abstract data types. One important
 	% advantage of this arrangement is to make it harder to accidentally
@@ -62,6 +63,14 @@
 	% integers and pred_ids/proc_ids with the following predicates and
 	% functions.
 
+:- func shroud_pred_id(pred_id) = shrouded_pred_id.
+:- func shroud_proc_id(proc_id) = shrouded_proc_id.
+:- func shroud_pred_proc_id(pred_proc_id) = shrouded_pred_proc_id.
+
+:- func unshroud_pred_id(shrouded_pred_id) = pred_id.
+:- func unshroud_proc_id(shrouded_proc_id) = proc_id.
+:- func unshroud_pred_proc_id(shrouded_pred_proc_id) = pred_proc_id.
+
 :- pred pred_id_to_int(pred_id, int).
 :- mode pred_id_to_int(in, out) is det.
 :- mode pred_id_to_int(out, in) is det.
@@ -111,7 +120,6 @@
 
 :- type simple_call_id == pair(pred_or_func, sym_name_and_arity).
 
-:- type pred_proc_id	--->	proc(pred_id, proc_id).
 :- type pred_proc_list	==	list(pred_proc_id).
 
 :- type prog_var_name == string.
@@ -882,6 +890,16 @@
 :- type pred_id		==	int.
 :- type proc_id		==	int.
 
+shroud_pred_id(PredId) = shrouded_pred_id(PredId).
+shroud_proc_id(ProcId) = shrouded_proc_id(ProcId).
+shroud_pred_proc_id(proc(PredId, ProcId)) =
+	shrouded_pred_proc_id(PredId, ProcId).
+
+unshroud_pred_id(shrouded_pred_id(PredId)) = PredId.
+unshroud_proc_id(shrouded_proc_id(ProcId)) = ProcId.
+unshroud_pred_proc_id(shrouded_pred_proc_id(PredId, ProcId)) =
+	proc(PredId, ProcId).
+
 pred_id_to_int(PredId, PredId).
 pred_id_to_int(PredId) = PredId.
 
@@ -2639,76 +2657,6 @@
 
 %-----------------------------------------------------------------------------%
 
-:- interface.
-
-	% make_n_fresh_vars(Name, N, VarSet0, Vars, VarSet):
-	%	`Vars' is a list of `N' fresh variables allocated from
-	%	`VarSet0'.  The variables will be named "<Name>1", "<Name>2",
-	%	"<Name>3", and so on, where <Name> is the value of `Name'.
-	%	`VarSet' is the resulting varset.
-
-:- pred make_n_fresh_vars(string::in, int::in, list(var(T))::out,
-	varset(T)::in, varset(T)::out) is det.
-
-	% given the list of predicate arguments for a predicate that
-	% is really a function, split that list into the function arguments
-	% and the function return type.
-:- pred pred_args_to_func_args(list(T)::in, list(T)::out, T::out) is det.
-
-	% Get the last two arguments from the list, failing if there
-	% aren't at least two arguments.
-:- pred get_state_args(list(T)::in, list(T)::out, T::out, T::out) is semidet.
-
-	% Get the last two arguments from the list, aborting if there
-	% aren't at least two arguments.
-:- pred get_state_args_det(list(T)::in, list(T)::out, T::out, T::out) is det.
-
-:- implementation.
-
-make_n_fresh_vars(BaseName, N, Vars, VarSet0, VarSet) :-
-	make_n_fresh_vars_2(BaseName, 0, N, Vars, VarSet0, VarSet).
-
-:- pred make_n_fresh_vars_2(string::in, int::in, int::in, list(var(T))::out,
-	varset(T)::in, varset(T)::out) is det.
-
-make_n_fresh_vars_2(BaseName, N, Max, Vars, !VarSet) :-
-	(N = Max ->
-		Vars = []
-	;
-		N1 = N + 1,
-		varset__new_var(!.VarSet, Var, !:VarSet),
-		string__int_to_string(N1, Num),
-		string__append(BaseName, Num, VarName),
-		varset__name_var(!.VarSet, Var, VarName, !:VarSet),
-		Vars = [Var | Vars1],
-		make_n_fresh_vars_2(BaseName, N1, Max, Vars1, !VarSet)
-	).
-
-pred_args_to_func_args(PredArgs, FuncArgs, FuncReturn) :-
-	list__length(PredArgs, NumPredArgs),
-	NumFuncArgs = NumPredArgs - 1,
-	( list__split_list(NumFuncArgs, PredArgs, FuncArgs0, [FuncReturn0]) ->
-		FuncArgs = FuncArgs0,
-		FuncReturn = FuncReturn0
-	;
-		error("pred_args_to_func_args: function missing return value?")
-	).
-
-get_state_args(Args0, Args, State0, State) :-
-	list__reverse(Args0, RevArgs0),
-	RevArgs0 = [State, State0 | RevArgs],
-	list__reverse(RevArgs, Args).
-
-get_state_args_det(Args0, Args, State0, State) :-
-	( get_state_args(Args0, Args1, State0A, StateA) ->
-		Args = Args1,
-		State0 = State0A,
-		State = StateA
-	;
-		error("hlds_pred__get_state_args_det")
-	).
-
-%-----------------------------------------------------------------------------%
 	% Predicates to deal with record syntax.
 
 :- interface.
@@ -2980,9 +2928,6 @@
 	% the given determinism.
 :- func valid_determinism_for_eval_method(eval_method, determinism) = bool.
 
-	% Convert an evaluation method to a string.
-:- func eval_method_to_string(eval_method) = string.
-
 	% Return true if the given evaluation method requires a
 	% stratification check.
 :- func eval_method_needs_stratification(eval_method) = bool.
@@ -3048,27 +2993,6 @@
 	;
 		Valid = no
 	).
-
-eval_method_to_string(eval_normal) =		"normal".
-eval_method_to_string(eval_loop_check) =	"loop_check".
-eval_method_to_string(eval_memo) =		"memo".
-eval_method_to_string(eval_minimal) = 		"minimal_model".
-eval_method_to_string(eval_table_io(IsDecl, IsUnitize)) = Str :-
-	(
-                IsDecl = table_io_decl,
-                DeclStr = "decl, "
-        ;
-                IsDecl = table_io_proc,
-                DeclStr = "proc, "
-        ),
-        (
-                IsUnitize = table_io_unitize,
-                UnitizeStr = "unitize"
-        ;
-                IsUnitize = table_io_alone,
-                UnitizeStr = "alone"
-        ),
-	Str = "table_io(" ++ DeclStr ++ UnitizeStr ++ ")".
 
 eval_method_needs_stratification(eval_normal) = no.
 eval_method_needs_stratification(eval_loop_check) = no.
Index: il_peephole.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/il_peephole.m,v
retrieving revision 1.9
diff -u -b -r1.9 il_peephole.m
Index: ilasm.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ilasm.m,v
retrieving revision 1.37
diff -u -b -r1.37 ilasm.m
Index: ilds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ilds.m,v
retrieving revision 1.17
diff -u -b -r1.17 ilds.m
Index: inst.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/inst.m,v
retrieving revision 1.11
diff -u -b -r1.11 inst.m
--- inst.m	27 Mar 2003 05:33:43 -0000	1.11
+++ inst.m	12 Jun 2004 17:10:33 -0000
@@ -4,113 +4,6 @@
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
 %
-% inst.m - Contains the (inst) data type.
-% Main author: bromage
-%
-%-----------------------------------------------------------------------------%
+% The former contents of this file are now prog_data.m.
 
-:- module parse_tree__inst.
-:- interface.
-
-% This module should NOT import hlds*.m.  Any types which are needed in
-% both the insts and in the HLDS should be defined here, rather than
-% in hlds*.m, because insts are part of the parse tree and the parse tree
-% should not depend on the HLDS.
-%
-% XXX Currently we have to import hlds_data for the `cons_id' type.
-%     I think the cons_ids in insts only use a subset of the functors
-%     of the `cons_id' type, and so we could define a new type
-%     `abstract_cons_id' and use that here instead of `cons_id'.
-
-:- import_module hlds__hlds_data.
-:- import_module parse_tree__prog_data.
-
-:- import_module list, map, set.
-
-%-----------------------------------------------------------------------------%
-%-----------------------------------------------------------------------------%
-
-:- type (inst)
-	--->		any(uniqueness)
-	;		free
-	;		free(type)
-	;		bound(uniqueness, list(bound_inst))
-				% The list(bound_inst) must be sorted
-	;		ground(uniqueness, ground_inst_info)
-				% The ground_inst_info holds extra information
-				% about the ground inst.
-	;		not_reached
-	;		inst_var(inst_var)
-				% constrained_inst_vars is a set of inst
-				% variables that are constrained to have the
-				% same uniqueness as and to match_final the
-				% specified inst.
-	;		constrained_inst_vars(set(inst_var), inst)
-				% A defined_inst is possibly recursive
-				% inst whose value is stored in the
-				% inst_table.  This is used both for
-				% user-defined insts and for
-				% compiler-generated insts.
-	;		defined_inst(inst_name)
-				% An abstract inst is a defined inst which
-				% has been declared but not actually been
-				% defined (yet).
-	;		abstract_inst(sym_name, list(inst)).
-
-:- type uniqueness
-	--->		shared		% there might be other references
-	;		unique		% there is only one reference
-	;		mostly_unique	% there is only one reference
-					% but there might be more on
-					% backtracking
-	;		clobbered	% this was the only reference, but
-					% the data has already been reused
-	;		mostly_clobbered.
-					% this was the only reference, but
-					% the data has already been reused;
-					% however, there may be more references
-					% on backtracking, so we will need to
-					% restore the old value on backtracking
-
-	% The ground_inst_info type gives extra information about ground insts.
-:- type ground_inst_info
-	--->	higher_order(pred_inst_info)
-			% The ground inst is higher-order.
-	;	none.
-			% No extra information is available.
-
-	% higher-order predicate terms are given the inst
-	%	`ground(shared, higher_order(PredInstInfo))'
-	% where the PredInstInfo contains the extra modes and the determinism
-	% for the predicate.  Note that the higher-order predicate term
-	% itself must be ground.
-
-:- type pred_inst_info
-	---> pred_inst_info(
-			pred_or_func,		% is this a higher-order func
-						% mode or a higher-order pred
-						% mode?
-			list(mode),		% the modes of the additional
-						% (i.e. not-yet-supplied)
-						% arguments of the pred;
-						% for a function, this includes
-						% the mode of the return value
-						% as the last element of the
-						% list.
-			determinism		% the determinism of the
-						% predicate or function
-	).
-
-:- type bound_inst	--->	functor(cons_id, list(inst)).
-
-:- type inst_var_sub == map(inst_var, inst).
-
-%-----------------------------------------------------------------------------%
-%-----------------------------------------------------------------------------%
-
-:- implementation.
-
-	% Empty for now.
-
-%-----------------------------------------------------------------------------%
-%-----------------------------------------------------------------------------%
+:- module (inst).
Index: inst_match.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/inst_match.m,v
retrieving revision 1.57
diff -u -b -r1.57 inst_match.m
--- inst_match.m	5 Dec 2003 04:18:24 -0000	1.57
+++ inst_match.m	12 Jun 2004 10:05:04 -0000
@@ -9,29 +9,27 @@
 %
 % This module defines some utility routines for comparing insts
 % that are used by modes.m and det_analysis.m.
-
-/*
-The handling of `any' insts is not complete.  (See also inst_util.m)
-It would be nice to allow `free' to match `any', but right now we
-only allow a few special cases of that.
-The reason is that although the mode analysis would be pretty
-straight-forward, generating the correct code is quite a bit trickier.
-modes.m would have to be changed to handle the implicit
-conversions from `free'/`bound'/`ground' to `any' at
-
-	(1) procedure calls (this is just an extension of implied modes)
-		currently we support only the easy cases of this
-	(2) the end of branched goals
-	(3) the end of predicates.
-
-Since that is not yet done, we currently require the user to
-insert explicit calls to initialize constraint variables.
-
-We do allow `bound' and `ground' to match `any', based on the
-assumption that `bound' and `ground' are represented in the same
-way as `any', i.e. that we use the type system rather than the
-mode system to distinguish between different representations.
-*/
+%
+% The handling of `any' insts is not complete.  (See also inst_util.m)
+% It would be nice to allow `free' to match `any', but right now we
+% only allow a few special cases of that.
+% The reason is that although the mode analysis would be pretty
+% straight-forward, generating the correct code is quite a bit trickier.
+% modes.m would have to be changed to handle the implicit
+% conversions from `free'/`bound'/`ground' to `any' at
+%
+% 	(1) procedure calls (this is just an extension of implied modes)
+% 		currently we support only the easy cases of this
+% 	(2) the end of branched goals
+% 	(3) the end of predicates.
+%
+% Since that is not yet done, we currently require the user to
+% insert explicit calls to initialize constraint variables.
+%
+% We do allow `bound' and `ground' to match `any', based on the
+% assumption that `bound' and `ground' are represented in the same
+% way as `any', i.e. that we use the type system rather than the
+% mode system to distinguish between different representations.
 
 %-----------------------------------------------------------------------------%
 
@@ -40,7 +38,6 @@
 :- interface.
 
 :- import_module hlds__hlds_module.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__prog_data.
 
 :- import_module list.
Index: inst_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/inst_util.m,v
retrieving revision 1.28
diff -u -b -r1.28 inst_util.m
--- inst_util.m	21 Dec 2003 05:04:34 -0000	1.28
+++ inst_util.m	12 Jun 2004 14:39:26 -0000
@@ -9,41 +9,37 @@
 %
 % This module defines some utility routines for manipulating insts.
 %
-
-/*
-The handling of `any' insts is not complete.  (See also inst_match.m)
-
-The major limitation is that we don't allow `free' to be passed
-where `any' is expected.  To handle that, modes.m would have to be
-changed to handle the implicit conversions from `free' to `any' at
-
-	(1) procedure calls (this is just an extension of implied modes)
-	(2) the end of branched goals
-	(3) the end of predicates.
-
-Since that is not yet done, we currently require the user to
-insert explicit calls to initialize constraint variables.
-
-Another limitation is that we don't allow any unifications between functors
-and variables of mode `any'; the reason for that is that I have no
-idea what code we should generate for them.  Currently `any' insts
-are only used for abstract types, so the type system should prevent
-any unification between functors and variables of mode `any'.
-
-Another limitation is that currently code generation assumes that insts
-`bound', `ground', and `any' are all represented the same way.
-That works fine for the CLP(R) interface but might not be ideal
-in the general case.
-*/
+%
+% The handling of `any' insts is not complete.  (See also inst_match.m)
+%
+% The major limitation is that we don't allow `free' to be passed
+% where `any' is expected.  To handle that, modes.m would have to be
+% changed to handle the implicit conversions from `free' to `any' at
+%
+% 	(1) procedure calls (this is just an extension of implied modes)
+% 	(2) the end of branched goals
+% 	(3) the end of predicates.
+%
+% Since that is not yet done, we currently require the user to
+% insert explicit calls to initialize constraint variables.
+%
+% Another limitation is that we don't allow any unifications between functors
+% and variables of mode `any'; the reason for that is that I have no
+% idea what code we should generate for them.  Currently `any' insts
+% are only used for abstract types, so the type system should prevent
+% any unification between functors and variables of mode `any'.
+%
+% Another limitation is that currently code generation assumes that insts
+% `bound', `ground', and `any' are all represented the same way.
+% That works fine for the CLP(R) interface but might not be ideal
+% in the general case.
 
 %-----------------------------------------------------------------------------%
 
 :- module check_hlds__inst_util.
 :- interface.
 
-:- import_module hlds__hlds_data.
 :- import_module hlds__hlds_module.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__prog_data.
 
 :- import_module list, std_util.
@@ -139,6 +135,7 @@
 :- import_module check_hlds__mode_util.
 :- import_module check_hlds__type_util.
 :- import_module hlds__hlds_data.
+:- import_module parse_tree__prog_mode.
 
 :- import_module bool, std_util, require, map, list, set, int.
 
@@ -295,12 +292,11 @@
 			BoundInsts, Det1, M),
 	det_par_conjunction_detism(Det1, semidet, Det).
 
-/*** abstract insts not supported
-abstractly_unify_inst_3(live, bound(Uniq, List), abstract_inst(_,_), Real, M,
-					ground(shared), semidet, M) :-
-	unify_uniq(live, Real, semidet, unique, UniqY, Uniq),
-	bound_inst_list_is_ground(List, M).
-***/
+% abstract insts not supported
+% abstractly_unify_inst_3(live, bound(Uniq, List), abstract_inst(_,_), Real, M,
+% 					ground(shared), semidet, M) :-
+% 	unify_uniq(live, Real, semidet, unique, UniqY, Uniq),
+% 	bound_inst_list_is_ground(List, M).
 
 abstractly_unify_inst_3(live, ground(UniqX, higher_order(PredInst)),
 		any(UniqY), Real, M, ground(Uniq, higher_order(PredInst)),
@@ -343,22 +339,21 @@
 % abstractly_unify_inst_3(live, abstract_inst(_,_), free,       _, _, _, _, _)
 %       :- fail.
 
-/*** abstract insts not supported
-abstractly_unify_inst_3(live, abstract_inst(_,_), bound(Uniq, List), Real,
-		ModuleInfo, ground(shared, no), semidet, ModuleInfo) :-
-	check_not_clobbered(Real, Uniq),
-	bound_inst_list_is_ground(List, ModuleInfo).
-
-abstractly_unify_inst_3(live, abstract_inst(_,_), ground(Uniq, no), Real, M,
-				ground(shared, no), semidet, M) :-
-	check_not_clobbered(Real, Uniq).
-
-abstractly_unify_inst_3(live, abstract_inst(Name, ArgsA),
-			abstract_inst(Name, ArgsB), Real, ModuleInfo0,
-			abstract_inst(Name, Args), Det, ModuleInfo) :-
-	abstractly_unify_inst_list(ArgsA, ArgsB, live, Real, ModuleInfo0,
-		Args, Det, ModuleInfo).
-***/
+% abstract insts not supported
+% abstractly_unify_inst_3(live, abstract_inst(_,_), bound(Uniq, List), Real,
+% 		ModuleInfo, ground(shared, no), semidet, ModuleInfo) :-
+% 	check_not_clobbered(Real, Uniq),
+% 	bound_inst_list_is_ground(List, ModuleInfo).
+%
+% abstractly_unify_inst_3(live, abstract_inst(_,_), ground(Uniq, no), Real, M,
+% 				ground(shared, no), semidet, M) :-
+% 	check_not_clobbered(Real, Uniq).
+%
+% abstractly_unify_inst_3(live, abstract_inst(Name, ArgsA),
+% 			abstract_inst(Name, ArgsB), Real, ModuleInfo0,
+% 			abstract_inst(Name, Args), Det, ModuleInfo) :-
+% 	abstractly_unify_inst_list(ArgsA, ArgsB, live, Real, ModuleInfo0,
+% 		Args, Det, ModuleInfo).
 
 abstractly_unify_inst_3(dead, not_reached, _, _, M, not_reached, det, M).
 
@@ -392,19 +387,18 @@
 					BoundInsts, Det1, M),
 	det_par_conjunction_detism(Det1, semidet, Det).
 
-/***** abstract insts aren't really supported
-abstractly_unify_inst_3(dead, bound(Uniq, List), abstract_inst(N,As),
-			ModuleInfo, Result, Det, ModuleInfo) :-
-	( bound_inst_list_is_ground(List, ModuleInfo) ->
-		Result = bound(Uniq, List),
-		Det = semidet
-	; bound_inst_list_is_free(List, ModuleInfo) ->
-		Result = abstract_inst(N,As),
-		Det = det
-	;
-		fail
-	).
-*****/
+% abstract insts aren't really supported
+% abstractly_unify_inst_3(dead, bound(Uniq, List), abstract_inst(N,As),
+% 			ModuleInfo, Result, Det, ModuleInfo) :-
+% 	( bound_inst_list_is_ground(List, ModuleInfo) ->
+% 		Result = bound(Uniq, List),
+% 		Det = semidet
+% 	; bound_inst_list_is_free(List, ModuleInfo) ->
+% 		Result = abstract_inst(N,As),
+% 		Det = det
+% 	;
+% 		fail
+% 	).
 
 abstractly_unify_inst_3(dead, ground(UniqX, higher_order(PredInst)),
 		any(UniqY), Real, M, ground(Uniq, higher_order(PredInst)),
@@ -434,29 +428,27 @@
 				Inst, Det, M) :-
 	make_ground_inst(Inst0, dead, Uniq, Real, M0, Inst, Det, M).
 
-/***** abstract insts aren't really supported
-abstractly_unify_inst_3(dead, abstract_inst(N,As), bound(List), Real,
-			ModuleInfo, Result, Det, ModuleInfo) :-
-	( bound_inst_list_is_ground(List, ModuleInfo) ->
-		Result = bound(List),
-		Det = semidet
-	; bound_inst_list_is_free(List, ModuleInfo) ->
-		Result = abstract_inst(N,As),
-		Det = det
-	;
-		fail
-	).
-
-abstractly_unify_inst_3(dead, abstract_inst(_,_), ground, _Real, ModuleInfo,
-		ground, semidet, ModuleInfo).
-
-abstractly_unify_inst_3(dead, abstract_inst(Name, ArgsA),
-			abstract_inst(Name, ArgsB), Real, ModuleInfo0,
-			abstract_inst(Name, Args), Det, ModuleInfo) :-
-	abstractly_unify_inst_list(ArgsA, ArgsB, dead, Real, ModuleInfo0,
-			Args, Det, ModuleInfo).
-
-*****/
+% abstract insts aren't really supported
+% abstractly_unify_inst_3(dead, abstract_inst(N,As), bound(List), Real,
+% 			ModuleInfo, Result, Det, ModuleInfo) :-
+% 	( bound_inst_list_is_ground(List, ModuleInfo) ->
+% 		Result = bound(List),
+% 		Det = semidet
+% 	; bound_inst_list_is_free(List, ModuleInfo) ->
+% 		Result = abstract_inst(N,As),
+% 		Det = det
+% 	;
+% 		fail
+% 	).
+%
+% abstractly_unify_inst_3(dead, abstract_inst(_,_), ground, _Real, ModuleInfo,
+% 		ground, semidet, ModuleInfo).
+%
+% abstractly_unify_inst_3(dead, abstract_inst(Name, ArgsA),
+% 			abstract_inst(Name, ArgsB), Real, ModuleInfo0,
+% 			abstract_inst(Name, Args), Det, ModuleInfo) :-
+% 	abstractly_unify_inst_list(ArgsA, ArgsB, dead, Real, ModuleInfo0,
+% 			Args, Det, ModuleInfo).
 
 %-----------------------------------------------------------------------------%
 
@@ -1148,7 +1140,6 @@
 maybe_make_shared_inst_list([_|_], [], _, _, _) :-
 	error("maybe_make_shared_inst_list: length mismatch").
 
-
 make_shared_inst_list([], ModuleInfo, [], ModuleInfo).
 make_shared_inst_list([Inst0 | Insts0], ModuleInfo0,
 		[Inst | Insts], ModuleInfo) :-
@@ -1417,7 +1408,6 @@
 		inst_merge_2(InstA, InstB, MaybeType, ModuleInfo1, Inst0,
 			ModuleInfo2),
 			
-
 			% now update the value associated with ThisInstPair
 		module_info_insts(ModuleInfo2, InstTable2),
 		inst_table_get_merge_insts(InstTable2, MergeInstTable2),
@@ -1708,7 +1698,6 @@
 			ModuleInfo = ModuleInfo0
 		)
 	).
-	
 
 %-----------------------------------------------------------------------------%
 
Index: instmap.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/instmap.m,v
retrieving revision 1.33
diff -u -b -r1.33 instmap.m
--- instmap.m	1 Dec 2003 15:55:38 -0000	1.33
+++ instmap.m	12 Jun 2004 10:05:04 -0000
@@ -21,10 +21,8 @@
 
 :- import_module check_hlds__mode_errors.
 :- import_module check_hlds__mode_info.
-:- import_module hlds__hlds_data.
 :- import_module hlds__hlds_module.
 :- import_module hlds__hlds_pred.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__prog_data.
 
 :- import_module map, bool, set, list, assoc_list, std_util.
Index: intermod.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/intermod.m,v
retrieving revision 1.160
diff -u -b -r1.160 intermod.m
--- intermod.m	7 Jun 2004 09:06:45 -0000	1.160
+++ intermod.m	12 Jun 2004 10:05:04 -0000
@@ -100,7 +100,6 @@
 :- import_module hlds__special_pred.
 :- import_module libs__globals.
 :- import_module libs__options.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__mercury_to_mercury.
 :- import_module parse_tree__modules.
 :- import_module parse_tree__prog_data.
@@ -715,11 +714,12 @@
 		RHS, DoWrite, !Info) :-
 	% Is this a higher-order predicate or higher-order function
 	% term?
-	( Functor = pred_const(PredId, _, _) ->
+	( Functor = pred_const(ShroudedPredProcId, _) ->
 		%
 		% Yes, the unification creates a higher-order term.
 		% Make sure that the predicate/function is exported.
 		%
+		proc(PredId, _) = unshroud_pred_proc_id(ShroudedPredProcId),
 		intermod__add_proc(PredId, DoWrite, !Info)
 	;
 		%
Index: ite_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ite_gen.m,v
retrieving revision 1.74
diff -u -b -r1.74 ite_gen.m
Index: java_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/java_util.m,v
retrieving revision 1.10
diff -u -b -r1.10 java_util.m
Index: lambda.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/lambda.m,v
retrieving revision 1.89
diff -u -b -r1.89 lambda.m
--- lambda.m	7 Jun 2004 09:06:46 -0000	1.89
+++ lambda.m	12 Jun 2004 16:08:49 -0000
@@ -84,6 +84,7 @@
 
 % Parse tree modules
 :- import_module parse_tree__prog_data.
+:- import_module parse_tree__prog_mode.
 :- import_module parse_tree__prog_util.
 
 % HLDS modules
@@ -568,7 +569,8 @@
 		module_info_set_predicate_table(PredicateTable,
 			ModuleInfo1, ModuleInfo)
 	),
-	ConsId = pred_const(PredId, ProcId, EvalMethod),
+	ShroudedPredProcId = shroud_pred_proc_id(proc(PredId, ProcId)),
+	ConsId = pred_const(ShroudedPredProcId, EvalMethod),
 	Functor = functor(ConsId, no, ArgVars),
 
 	Unification = construct(Var, ConsId, ArgVars, UniModes,
Index: lco.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/lco.m,v
retrieving revision 1.21
diff -u -b -r1.21 lco.m
Index: live_vars.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/live_vars.m,v
retrieving revision 1.105
diff -u -b -r1.105 live_vars.m
Index: livemap.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/livemap.m,v
retrieving revision 1.60
diff -u -b -r1.60 livemap.m
Index: liveness.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/liveness.m,v
retrieving revision 1.128
diff -u -b -r1.128 liveness.m
--- liveness.m	7 Jun 2004 09:06:48 -0000	1.128
+++ liveness.m	12 Jun 2004 10:05:04 -0000
@@ -179,7 +179,6 @@
 :- implementation.
 
 % Parse tree modules
-:- import_module parse_tree__inst.
 :- import_module parse_tree__prog_util.
 
 % HLDS modules
Index: llds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds.m,v
retrieving revision 1.306
diff -u -b -r1.306 llds.m
--- llds.m	7 Jun 2004 09:06:49 -0000	1.306
+++ llds.m	12 Jun 2004 10:05:05 -0000
@@ -26,7 +26,6 @@
 :- import_module hlds__hlds_pred.
 :- import_module libs__tree.
 :- import_module ll_backend__layout.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__prog_data.
 
 :- import_module bool, list, assoc_list, map, set, std_util, counter, term.
Index: lookup_switch.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/lookup_switch.m,v
retrieving revision 1.53
diff -u -b -r1.53 lookup_switch.m
Index: loop_inv.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/loop_inv.m,v
retrieving revision 1.10
diff -u -b -r1.10 loop_inv.m
--- loop_inv.m	7 Jun 2004 09:06:50 -0000	1.10
+++ loop_inv.m	12 Jun 2004 10:05:05 -0000
@@ -129,7 +129,6 @@
 :- import_module hlds__instmap.
 :- import_module hlds__quantification.
 :- import_module parse_tree__error_util.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__prog_data.
 :- import_module parse_tree__prog_util.
 
Index: lp.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/lp.m,v
retrieving revision 1.8
diff -u -b -r1.8 lp.m
Index: magic.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/magic.m,v
retrieving revision 1.44
diff -u -b -r1.44 magic.m
--- magic.m	7 Jun 2004 09:06:51 -0000	1.44
+++ magic.m	12 Jun 2004 14:20:03 -0000
@@ -192,8 +192,8 @@
 :- import_module libs__options.
 :- import_module ll_backend.
 :- import_module ll_backend__saved_vars.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__prog_data.
+:- import_module parse_tree__prog_mode.
 :- import_module parse_tree__prog_out.
 :- import_module transform_hlds__dead_proc_elim.
 :- import_module transform_hlds__dependency_graph.
@@ -1440,7 +1440,7 @@
 magic__preprocess_goal_2(Goal0, Goals, HOMap0, HOMap) -->
 	{ Goal0 = unify(_, _, _, Uni, _) - GoalInfo },
 	(
-		{ Uni = construct(Var, pred_const(_, _, _), Args, _, _, _, _) }
+		{ Uni = construct(Var, pred_const(_, _), Args, _, _, _, _) }
 	->
 		% Collect up the closure construction so that it can be
 		% placed next to the aggregate goal that uses it.
@@ -1571,14 +1571,16 @@
 				Goal, _, _)
 		;
 			Goal = unify(_, _, _, Uni, _) - _,
-			Uni = construct(_, pred_const(PredId, ProcId, _),
+			Uni = construct(_, pred_const(ShroudedPredProcId, _),
 				_, _, _, _, _),
+			PredProcId = unshroud_pred_proc_id(ShroudedPredProcId),
 			% XXX once the implementation of aggregates has
 			% been updated to use `aditi_bottom_up' closures,
 			% this can be done by just checking the eval_method.
 			(
-				map__contains(PredMap, proc(PredId, ProcId))
+				map__contains(PredMap, PredProcId)
 			;
+				PredProcId = proc(PredId, _),
 				hlds_pred__is_aditi_relation(ModuleInfo,
 					PredId)
 			)
Index: magic_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/magic_util.m,v
retrieving revision 1.38
diff -u -b -r1.38 magic_util.m
--- magic_util.m	14 May 2004 08:40:24 -0000	1.38
+++ magic_util.m	12 Jun 2004 10:13:25 -0000
@@ -130,7 +130,6 @@
 :- import_module hlds__hlds_error_util.
 :- import_module hlds__hlds_out.
 :- import_module hlds__instmap.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__error_util.
 :- import_module parse_tree__prog_out.
 :- import_module parse_tree__prog_util.
@@ -269,7 +268,7 @@
 
 magic_util__check_aggregate_closure(Goal, Goal) :-
 	Goal = unify(_, _, _, Uni, _) - _,
-	Uni = construct(_, pred_const(_, _, _), _, _, _, _, _).	
+	Uni = construct(_, pred_const(_, _), _, _, _, _, _).
 
 :- pred magic_util__construct_db_call(module_info::in, pred_id::in,
 	proc_id::in, list(prog_var)::in, hlds_goal::in, db_call::out) is det.
@@ -453,21 +452,22 @@
 	(
 		{ Closure = unify(_, _, UniMode, Uni0, Context) - Info },
 		{ Uni0 = construct(Var, ConsId0, _, Modes, _, _, _) },
-		{ ConsId0 = pred_const(PredId0, ProcId0, Method) }
+		{ ConsId0 = pred_const(ShroudedPredProcId0, Method) }
 	->
 		%
 		% Replace the pred_proc_id of the procedure being aggregated
 		% over with its Aditi version.
 		%
-		{ map__search(PredMap, proc(PredId0, ProcId0), PredProcId) ->
-			PredProcId = proc(PredId, ProcId),
-			ConsId = pred_const(PredId, ProcId, Method)
+		{ PredProcId0 = unshroud_pred_proc_id(ShroudedPredProcId0) },
+		{ map__search(PredMap, PredProcId0, PredProcIdPrime) ->
+			PredProcId = PredProcIdPrime,
+			ShroudedPredProcId = shroud_pred_proc_id(PredProcId),
+			ConsId = pred_const(ShroudedPredProcId, Method)
 		;
-			PredId = PredId0,
-			ProcId = ProcId0,
+			PredProcId = PredProcId0,
 			ConsId = ConsId0
 		},
-
+		{ PredProcId = proc(PredId, _ProcId) },
 		( { hlds_pred__is_derived_relation(ModuleInfo0, PredId) } ->
 
 			%
@@ -476,7 +476,7 @@
 			% arguments (except for aditi:states).
 			%
 			magic_info_get_magic_proc_info(MagicProcInfo),
-			{ map__lookup(MagicProcInfo, proc(PredId, ProcId),
+			{ map__lookup(MagicProcInfo, PredProcId,
 				CallProcInfo) },
 			{ CallProcInfo = magic_proc_info(_, MagicInputs,
 						_, _, _) },
@@ -841,8 +841,11 @@
 		{ Rhs = functor(cons(qualified(SuppModule, SuppName), 
 				SuppArity), no, LambdaInputs) },
 
+		{ SuppPredProcId = proc(SuppPredId, SuppProcId) },
+		{ ShroudedSuppPredProcId =
+			shroud_pred_proc_id(SuppPredProcId) },
 		{ Unify = construct(InputVar, 
-			pred_const(SuppPredId, SuppProcId, (aditi_bottom_up)), 
+			pred_const(ShroudedSuppPredProcId, (aditi_bottom_up)),
 			LambdaInputs, UniModes, construct_dynamically,
 			cell_is_unique, no) },
 		{ UnifyContext = unify_context(explicit, []) },
Index: make.dependencies.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.dependencies.m,v
retrieving revision 1.15
diff -u -b -r1.15 make.dependencies.m
Index: make.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.m,v
retrieving revision 1.20
diff -u -b -r1.20 make.m
Index: make.module_dep_file.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.module_dep_file.m,v
retrieving revision 1.8
diff -u -b -r1.8 make.module_dep_file.m
Index: make.module_target.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.module_target.m,v
retrieving revision 1.25
diff -u -b -r1.25 make.module_target.m
Index: make.program_target.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.program_target.m,v
retrieving revision 1.25
diff -u -b -r1.25 make.program_target.m
Index: make.util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.util.m,v
retrieving revision 1.19
diff -u -b -r1.19 make.util.m
Index: make_hlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make_hlds.m,v
retrieving revision 1.471
diff -u -b -r1.471 make_hlds.m
--- make_hlds.m	9 Jun 2004 07:56:11 -0000	1.471
+++ make_hlds.m	12 Jun 2004 15:32:01 -0000
@@ -121,7 +121,6 @@
 :- import_module ll_backend__fact_table.
 :- import_module ll_backend__llds.
 :- import_module parse_tree__error_util.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__mercury_to_mercury.
 :- import_module parse_tree__module_qual.
 :- import_module parse_tree__modules.
@@ -129,6 +128,7 @@
 :- import_module parse_tree__prog_io_dcg.
 :- import_module parse_tree__prog_io_goal.
 :- import_module parse_tree__prog_io_util.
+:- import_module parse_tree__prog_mode.
 :- import_module parse_tree__prog_out.
 :- import_module parse_tree__prog_util.
 :- import_module recompilation.
@@ -3293,7 +3293,7 @@
 			module_info_pred_info(!.Module, OrigPred,
 				OrigPredInfo),
 			pred_info_context(OrigPredInfo, OrigContext),
-			DeclString = hlds_out__pred_or_func_to_str(PredOrFunc),
+			DeclString = pred_or_func_to_str(PredOrFunc),
 			adjust_func_arity(PredOrFunc, OrigArity, Arity),
 			multiple_def_error(ItemStatus, PredName, OrigArity,
 				DeclString, Context, OrigContext, FoundError,
@@ -4093,7 +4093,7 @@
 	globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO),
 	( VeryVerbose = yes ->
 		io__write_string("% Processing clause for ", !IO),
-		hlds_out__write_pred_or_func(PredOrFunc, !IO),
+		write_pred_or_func(PredOrFunc, !IO),
 		io__write_string(" `", !IO),
 		list__length(Args, PredArity0),
 		PredArity = PredArity0 + ArityAdjustment,
@@ -8404,11 +8404,11 @@
 		prog_out__write_context(Context, !IO),
 		io__write_string("  (There are no declared modes for this ",
 			!IO),
-		hlds_out__write_pred_or_func(PredOrFunc, !IO),
+		write_pred_or_func(PredOrFunc, !IO),
 		io__write_string(".)\n", !IO)
 	; VerboseErrors = yes ->
 		io__write_string("\tThe declared modes for this ", !IO),
-		hlds_out__write_pred_or_func(PredOrFunc, !IO),
+		write_pred_or_func(PredOrFunc, !IO),
 		io__write_string(" are the following:\n", !IO),
 		OutputProc = (pred(ProcId::in, di, uo) is det -->
 			io__write_string("\t\t:- mode "),
@@ -8466,7 +8466,7 @@
 		io__write_string("\n"),
 		prog_out__write_context(Context),
 		io__write_string("  without preceding `"),
-		{ DeclString = hlds_out__pred_or_func_to_str(PredOrFunc) },
+		{ DeclString = pred_or_func_to_str(PredOrFunc) },
 		io__write_string(DeclString),
 		io__write_string("' declaration.\n")
 	).
Index: mark_static_terms.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mark_static_terms.m,v
retrieving revision 1.12
diff -u -b -r1.12 mark_static_terms.m
Index: maybe_mlds_to_gcc.pp
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/maybe_mlds_to_gcc.pp,v
retrieving revision 1.7
diff -u -b -r1.7 maybe_mlds_to_gcc.pp
--- maybe_mlds_to_gcc.pp	18 Mar 2003 02:43:37 -0000	1.7
+++ maybe_mlds_to_gcc.pp	13 Jun 2004 07:33:51 -0000
@@ -58,7 +58,7 @@
 
 #else
 
-:- import_module hlds__passes_aux.
+:- import_module parse_tree__prog_out.
 :- import_module string.
 
 maybe_mlds_to_gcc__run_gcc_backend(_ModuleName, CallBack, CallBackOutput) -->
Index: mercury_to_mercury.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_to_mercury.m,v
retrieving revision 1.242
diff -u -b -r1.242 mercury_to_mercury.m
--- mercury_to_mercury.m	9 Jun 2004 07:56:12 -0000	1.242
+++ mercury_to_mercury.m	12 Jun 2004 16:52:31 -0000
@@ -42,14 +42,10 @@
 :- module parse_tree__mercury_to_mercury.
 :- interface.
 
-:- import_module hlds__hlds_data.
-:- import_module hlds__hlds_goal.
-:- import_module hlds__hlds_module.
 :- import_module libs__globals.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__prog_data.
 
-:- import_module bool, std_util, list, io, varset, term.
+:- import_module bool, char, std_util, list, io, varset, term.
 
 :- type needs_brackets
 	--->	needs_brackets		% needs brackets, if it is an op
@@ -61,24 +57,20 @@
 	;	not_next_to_graphic_token.	% doesn't need quotes
 
 %	convert_to_mercury(ModuleName, OutputFileName, Items)
-:- pred convert_to_mercury(module_name, string, list(item_and_context),
-				io__state, io__state).
-:- mode convert_to_mercury(in, in, in, di, uo) is det.
+:- pred convert_to_mercury(module_name::in, string::in,
+	list(item_and_context)::in, io::di, io::uo) is det.
 
 %	mercury_output_item(Item, Context)
 %		output the specified item, followed by ".\n"
-:- pred mercury_output_item(item, prog_context, io__state, io__state).
-:- mode mercury_output_item(in, in, di, uo) is det.
+:- pred mercury_output_item(item::in, prog_context::in, io::di, io::uo) is det.
 
 	% Output a `:- pred' declaration, making sure that the variable
 	% number appears in variable names if the boolean argument
 	% is set to `yes'.
-:- pred mercury_output_pred_type(tvarset, existq_tvars, sym_name, list(type),
-		maybe(determinism), purity, class_constraints,
-		prog_context, bool, io__state, io__state).
-:- mode mercury_output_pred_type(in, in, in, in, in, in, in, in, in,
-		di, uo) is det.
-
+:- pred mercury_output_pred_type(tvarset::in, existq_tvars::in, sym_name::in,
+	list(type)::in, maybe(determinism)::in, purity::in,
+	class_constraints::in, prog_context::in, bool::in, io::di, io::uo)
+	is det.
 :- func mercury_pred_type_to_string(tvarset, existq_tvars, sym_name,
 	list(type), maybe(determinism), purity, class_constraints,
 	prog_context, bool) = string.
@@ -86,73 +78,56 @@
 	% Output a `:- func' declaration, making sure that the variable
 	% number appears in variable names if the boolean argument
 	% is set to `yes'.
-:- pred mercury_output_func_type(tvarset, existq_tvars, sym_name,
-		list(type), type,
-		maybe(determinism), purity, class_constraints,
-		prog_context, bool, io__state, io__state).
-:- mode mercury_output_func_type(in, in, in, in, in, in, in, in, in, in,
-		di, uo) is det.
-
+:- pred mercury_output_func_type(tvarset::in, existq_tvars::in, sym_name::in,
+	list(type)::in, (type)::in, maybe(determinism)::in, purity::in,
+	class_constraints::in, prog_context::in, bool::in, io::di, io::uo)
+	is det.
 :- func mercury_func_type_to_string(tvarset, existq_tvars, sym_name,
 	list(type), type, maybe(determinism), purity, class_constraints,
 	prog_context, bool) = string.
 
-:- pred mercury_output_pred_mode_decl(inst_varset, sym_name, list(mode),
-		maybe(determinism), prog_context, io__state, io__state).
-:- mode mercury_output_pred_mode_decl(in, in, in, in, in, di, uo) is det.
-
+:- pred mercury_output_pred_mode_decl(inst_varset::in, sym_name::in,
+	list(mode)::in, maybe(determinism)::in, prog_context::in,
+	io::di, io::uo) is det.
 :- func mercury_pred_mode_decl_to_string(inst_varset, sym_name, list(mode),
 	maybe(determinism), prog_context) = string.
 
-:- pred mercury_output_func_mode_decl(inst_varset, sym_name, list(mode), mode,
-		maybe(determinism), prog_context, io__state, io__state).
-:- mode mercury_output_func_mode_decl(in, in, in, in, in, in, di, uo) is det.
-
+:- pred mercury_output_func_mode_decl(inst_varset::in, sym_name::in,
+	list(mode)::in, (mode)::in, maybe(determinism)::in, prog_context::in,
+	io::di, io::uo) is det.
 :- func mercury_func_mode_decl_to_string(inst_varset, sym_name, list(mode),
 	mode, maybe(determinism), prog_context) = string.
 
-:- pred mercury_output_mode_subdecl(pred_or_func, inst_varset, sym_name,
-		list(mode), maybe(determinism), prog_context,
-		io__state, io__state).
-:- mode mercury_output_mode_subdecl(in, in, in, in, in, in, di, uo) is det.
-
+:- pred mercury_output_mode_subdecl(pred_or_func::in, inst_varset::in,
+	sym_name::in, list(mode)::in, maybe(determinism)::in, prog_context::in,
+	io::di, io::uo) is det.
 :- func mercury_mode_subdecl_to_string(pred_or_func, inst_varset, sym_name,
 	list(mode), maybe(determinism), prog_context) = string.
 
-:- pred mercury_output_pred_mode_subdecl(inst_varset, sym_name, list(mode),
-		maybe(determinism), prog_context, io__state, io__state).
-:- mode mercury_output_pred_mode_subdecl(in, in, in, in, in, di, uo) is det.
-
+:- pred mercury_output_pred_mode_subdecl(inst_varset::in, sym_name::in,
+	list(mode)::in, maybe(determinism)::in, prog_context::in,
+	io::di, io::uo) is det.
 :- func mercury_pred_mode_subdecl_to_string(inst_varset, sym_name, list(mode),
 	maybe(determinism), prog_context) = string.
 
-:- pred mercury_output_func_mode_subdecl(inst_varset, sym_name, list(mode),
-		mode, maybe(determinism), prog_context, io__state, io__state).
-:- mode mercury_output_func_mode_subdecl(in, in, in, in, in, in, di, uo) is det.
-
+:- pred mercury_output_func_mode_subdecl(inst_varset::in, sym_name::in,
+	list(mode)::in, (mode)::in, maybe(determinism)::in, prog_context::in,
+	io::di, io::uo) is det.
 :- func mercury_func_mode_subdecl_to_string(inst_varset, sym_name, list(mode),
 	mode, maybe(determinism), prog_context) = string.
 
-:- pred mercury_output_pragma_decl(sym_name, int, pred_or_func, string,
-		io__state, io__state).
-:- mode mercury_output_pragma_decl(in, in, in, in, di, uo) is det.
-
+:- pred mercury_output_pragma_decl(sym_name::in, int::in, pred_or_func::in,
+	string::in, io::di, io::uo) is det.
 :- func mercury_pragma_decl_to_string(sym_name, int, pred_or_func, string)
 	= string.
 
-:- pred mercury_output_foreign_language_string(foreign_language,
-		io__state, io__state).
-:- mode mercury_output_foreign_language_string(in, di, uo) is det.
-
+:- pred mercury_output_foreign_language_string(foreign_language::in,
+	io::di, io::uo) is det.
 :- func mercury_foreign_language_to_string(foreign_language) = string.
 
-:- pred mercury_output_pragma_foreign_code(
-		pragma_foreign_proc_attributes, sym_name,
-		pred_or_func, list(pragma_var), prog_varset,
-		pragma_foreign_code_impl, io__state, io__state).
-:- mode mercury_output_pragma_foreign_code(
-		in, in, in, in, in, in, di, uo) is det.
-
+:- pred mercury_output_pragma_foreign_code(pragma_foreign_proc_attributes::in,
+	sym_name::in, pred_or_func::in, list(pragma_var)::in, prog_varset::in,
+	pragma_foreign_code_impl::in, io::di, io::uo) is det.
 :- func mercury_pragma_foreign_code_to_string(pragma_foreign_proc_attributes,
 	sym_name, pred_or_func, list(pragma_var), prog_varset,
 	pragma_foreign_code_impl) = string.
@@ -161,87 +136,67 @@
 			ground, ground, ground, ground)).
 
 	% mercury_output_pragma_type_spec(Pragma, AppendVarnums).
-:- pred mercury_output_pragma_type_spec((pragma_type), bool,
-		io__state, io__state).
-:- mode mercury_output_pragma_type_spec(in(type_spec), in, di, uo) is det.
+:- pred mercury_output_pragma_type_spec((pragma_type)::in(type_spec), bool::in,
+	io::di, io::uo) is det.
 
-:- pred mercury_output_pragma_unused_args(pred_or_func, sym_name,
-		int, mode_num, list(int), io__state, io__state).
-:- mode mercury_output_pragma_unused_args(in, in, in, in, in, di, uo) is det.
+:- pred mercury_output_pragma_unused_args(pred_or_func::in, sym_name::in,
+	int::in, mode_num::in, list(int)::in, io::di, io::uo) is det.
 
 	% Write an Aditi index specifier.
-:- pred mercury_output_index_spec(index_spec, io__state, io__state).
-:- mode mercury_output_index_spec(in, di, uo) is det.
+:- pred mercury_output_index_spec(index_spec::in, io::di, io::uo) is det.
 
 	% Output the given foreign_decl declaration
 :- pred mercury_output_pragma_foreign_decl(foreign_language::in,
-	foreign_decl_is_local::in, string::in,
-	io::di, io::uo) is det.
-
+	foreign_decl_is_local::in, string::in, io::di, io::uo) is det.
 :- func mercury_pragma_foreign_decl_to_string(foreign_language,
 	foreign_decl_is_local, string) = string.
 
-:- pred mercury_output_pragma_foreign_import_module(foreign_language,
-		module_name, io__state, io__state).
-:- mode mercury_output_pragma_foreign_import_module(in, in, di, uo) is det.
+:- pred mercury_output_pragma_foreign_import_module(foreign_language::in,
+	module_name::in, io::di, io::uo) is det.
 
-:- pred mercury_output_ctor(constructor, tvarset, io__state, io__state).
-:- mode mercury_output_ctor(in, in, di, uo) is det.
+:- pred mercury_output_ctor(constructor::in, tvarset::in, io::di, io::uo)
+	is det.
 
-:- pred mercury_output_remaining_ctor_args(tvarset, list(constructor_arg),
-		io__state, io__state).
-:- mode mercury_output_remaining_ctor_args(in, in, di, uo) is det.
+:- pred mercury_output_remaining_ctor_args(tvarset::in,
+	list(constructor_arg)::in, io::di, io::uo) is det.
+
+:- pred mercury_output_inst_list(list(inst)::in, inst_varset::in,
+	io::di, io::uo) is det.
+:- func mercury_inst_list_to_string(list(inst), inst_varset) = string.
 
 	% Output a list of insts in a format that makes them easy to read
 	% but may not be valid Mercury.
 
-:- pred mercury_output_structured_inst_list(list(inst), int, inst_varset,
-			io__state, io__state).
-:- mode mercury_output_structured_inst_list(in, in, in, di, uo) is det.
-
+:- pred mercury_output_structured_inst_list(list(inst)::in, int::in,
+	inst_varset::in, io::di, io::uo) is det.
 :- func mercury_structured_inst_list_to_string(list(inst), int, inst_varset)
 	= string.
 
-:- pred mercury_output_inst_list(list(inst), inst_varset, io__state, io__state).
-:- mode mercury_output_inst_list(in, in, di, uo) is det.
-
-:- func mercury_inst_list_to_string(list(inst), inst_varset) = string.
-
 	% Output an inst in a format that makes it easy to read
 	% but may not be valid Mercury.
 	% The `int' argument specifies the indentation level.
 	% (These routines are used with `--debug-modes'.)
 
-:- pred mercury_output_structured_inst(inst, int, inst_varset,
-		io__state, io__state).
-:- mode mercury_output_structured_inst(in, in, in, di, uo) is det.
-
+:- pred mercury_output_structured_inst((inst)::in, int::in, inst_varset::in,
+	io::di, io::uo) is det.
 :- func mercury_structured_inst_to_string(inst, int, inst_varset) = string.
 
-	% Output an inst in a format where all compiler-defined insts
-	% have been expanded out; recursive insts have their self-referential
-	% parts printed out as elipses ("...").
-	% (These routines are used for outputting insts in mode errors.)
-
-:- pred mercury_output_expanded_inst(inst, inst_varset, module_info,
-		io__state, io__state).
-:- mode mercury_output_expanded_inst(in, in, in, di, uo) is det.
-
-:- func mercury_expanded_inst_to_string(inst, inst_varset, module_info)
-	= string.
-
 	% Output an inst in a format that is valid Mercury.
 	% (These routines are used to create `.int' files, etc.)
 
-:- pred mercury_output_inst(inst, inst_varset, io__state, io__state).
-:- mode mercury_output_inst(in, in, di, uo) is det.
-
+:- pred mercury_output_inst((inst)::in, inst_varset::in, io::di, io::uo)
+	is det.
 :- func mercury_inst_to_string(inst, inst_varset) = string.
+:- pred mercury_format_inst((inst)::in, InstInfo::in,
+	U::di, U::uo) is det <= (output(U), inst_info(InstInfo)).
+
+:- pred mercury_format_inst_name(inst_name::in, InstInfo::in,
+	U::di, U::uo) is det <= (output(U), inst_info(InstInfo)).
 
 	% Output a cons_id, parenthesizing it if necessary
 
-:- pred mercury_output_cons_id(cons_id, needs_brackets, io__state, io__state).
-:- mode mercury_output_cons_id(in, in, di, uo) is det.
+:- pred mercury_output_cons_id(cons_id::in, needs_brackets::in,
+	io::di, io::uo) is det.
 
 :- func mercury_cons_id_to_string(cons_id, needs_brackets) = string.
 
@@ -249,64 +204,46 @@
 	% in a format that is valid Mercury.
 	% (These routines are used to create `.int' files, etc.)
 
-:- pred mercury_output_mode(mode, inst_varset, io__state, io__state).
-:- mode mercury_output_mode(in, in, di, uo) is det.
-
+:- pred mercury_output_mode((mode)::in, inst_varset::in, io::di, io::uo)
+	is det.
 :- func mercury_mode_to_string(mode, inst_varset) = string.
 
-:- pred mercury_output_mode_list(list(mode), inst_varset, io__state, io__state).
-:- mode mercury_output_mode_list(in, in, di, uo) is det.
+:- pred mercury_format_mode((mode)::in, InstInfo::in,
+	U::di, U::uo) is det <= (output(U), inst_info(InstInfo)).
 
+:- pred mercury_output_mode_list(list(mode)::in, inst_varset::in,
+	io::di, io::uo) is det.
 :- func mercury_mode_list_to_string(list(mode), inst_varset) = string.
 
-:- pred mercury_output_uni_mode(uni_mode, inst_varset, io__state, io__state).
-:- mode mercury_output_uni_mode(in, in, di, uo) is det.
-
-:- func mercury_uni_mode_to_string(uni_mode, inst_varset) = string.
-
-:- pred mercury_output_uni_mode_list(list(uni_mode), inst_varset,
-		io__state, io__state).
-:- mode mercury_output_uni_mode_list(in, in, di, uo) is det.
-
-:- func mercury_uni_mode_list_to_string(list(uni_mode), inst_varset) = string.
-
 	% Output a determinism, in a format that is valid Mercury.
 
-:- pred mercury_output_det(determinism, io__state, io__state).
-:- mode mercury_output_det(in, di, uo) is det.
-
+:- pred mercury_output_det(determinism::in, io::di, io::uo) is det.
 :- func mercury_det_to_string(determinism) = string.
 
 	% Output a comma-separated list of variables, making sure that
 	% the variable number appears in the variable name if the boolean
 	% argument is set to `yes'.
 
-:- pred mercury_output_vars(list(var(T)), varset(T), bool,
-		io__state, io__state).
-:- mode mercury_output_vars(in, in, in, di, uo) is det.
-
+:- pred mercury_output_vars(list(var(T))::in, varset(T)::in, bool::in,
+	io::di, io::uo) is det.
 :- func mercury_vars_to_string(list(var(T)), varset(T), bool) = string.
 
 	% Output a variable, making sure that the variable number appears
 	% in the variable name if the boolean argument is set to `yes'.
 
-:- pred mercury_output_var(var(T), varset(T), bool, io__state, io__state).
-:- mode mercury_output_var(in, in, in, di, uo) is det.
-
+:- pred mercury_output_var(var(T)::in, varset(T)::in, bool::in,
+	io::di, io::uo) is det.
 :- func mercury_var_to_string(var(T), varset(T), bool) = string.
 
 	% Output a term, making sure that the variable number appears
 	% in variable names if the boolean argument is set to `yes'.
 
-:- pred mercury_output_term(term(T), varset(T), bool, io__state, io__state).
-:- mode mercury_output_term(in, in, in, di, uo) is det.
-
+:- pred mercury_output_term(term(T)::in, varset(T)::in, bool::in,
+	io::di, io::uo) is det.
 :- func mercury_term_to_string(term(T), varset(T), bool) = string.
 
-:- pred mercury_output_term(term(T), varset(T), bool, needs_quotes,
-		io__state, io__state).
-:- mode mercury_output_term(in, in, in, in, di, uo) is det.
-
+:- pred mercury_output_term(term(T)::in, varset(T)::in, bool::in,
+	needs_quotes::in, io::di, io::uo) is det.
 :- func mercury_term_to_string(term(T), varset(T), bool, needs_quotes)
 	= string.
 
@@ -316,39 +253,31 @@
 :- func mercury_type_to_string(tvarset, type) = string.
 :- func mercury_type_list_to_string(tvarset, list(type)) = string.
 
-:- pred mercury_output_newline(int, io__state, io__state).
-:- mode mercury_output_newline(in, di, uo) is det.
+:- pred mercury_output_newline(int::in, io::di, io::uo) is det.
 
-:- pred mercury_output_bracketed_sym_name(sym_name, io__state, io__state).
-:- mode mercury_output_bracketed_sym_name(in, di, uo) is det.
+:- pred mercury_output_bracketed_sym_name(sym_name::in,
+	io::di, io::uo) is det.
 
-:- pred mercury_output_bracketed_sym_name(sym_name, needs_quotes,
-		io__state, io__state).
-:- mode mercury_output_bracketed_sym_name(in, in, di, uo) is det.
+:- pred mercury_output_bracketed_sym_name(sym_name::in, needs_quotes::in,
+	io::di, io::uo) is det.
 
-:- pred mercury_convert_var_name(string, string).
-:- mode mercury_convert_var_name(in, out) is det.
+:- pred mercury_convert_var_name(string::in, string::out) is det.
 
 	% Output a constraint, making sure that the variable number appears
 	% in variable names if the boolean argument is set to `yes'.
-:- pred mercury_output_constraint(tvarset, bool, class_constraint,
-		io__state, io__state).
-:- mode mercury_output_constraint(in, in, in, di, uo) is det.
-
+:- pred mercury_output_constraint(tvarset::in, bool::in, class_constraint::in,
+	io::di, io::uo) is det.
 :- func mercury_constraint_to_string(tvarset, class_constraint) = string.
 
 	% Output an existential quantifier, making sure that the variable
 	% number appears in variable names if the boolean argument
 	% is set to `yes'.
-:- pred mercury_output_quantifier(tvarset, bool, existq_tvars,
-		io__state, io__state).
-:- mode mercury_output_quantifier(in, in, in, di, uo) is det.
-
+:- pred mercury_output_quantifier(tvarset::in, bool::in, existq_tvars::in,
+	io::di, io::uo) is det.
 :- func mercury_quantifier_to_string(tvarset, bool, existq_tvars) = string.
 
-:- pred mercury_output_instance_methods(instance_methods, io__state,
-	io__state).
-:- mode mercury_output_instance_methods(in, di, uo) is det.
+:- pred mercury_output_instance_methods(instance_methods::in,
+	io::di, io::uo) is det.
 
 	% This predicate outputs termination_info pragmas;
 	% such annotations can be part of .opt and .trans_opt files.
@@ -369,16 +298,59 @@
 	bool::in, io::di, io::uo) is det.
 
 %-----------------------------------------------------------------------------%
+
+% This is the typeclass mentioned in the long comment at the top of the module.
+
+:- 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,
+	pred add_int(int::in, U::di, U::uo) is det,
+	pred add_float(float::in, U::di, U::uo) is det,
+	pred add_purity_prefix(purity::in, U::di, U::uo) is det,
+	pred add_quoted_atom(string::in, U::di, U::uo) is det,
+	pred add_quoted_string(string::in, U::di, U::uo) is det,
+	pred add_constant(const::in, U::di, U::uo) is det,
+	pred add_class_id(class_id::in, U::di, U::uo) is det,
+	pred add_eval_method(eval_method::in, U::di, U::uo) is det,
+	pred add_lambda_eval_method(lambda_eval_method::in, U::di, U::uo)
+		is det,
+	pred add_index_type(index_type::in, U::di, U::uo) is det,
+	pred add_escaped_string(string::in, U::di, U::uo) is det,
+	pred add_format(string::in, list(io__poly_type)::in,
+		U::di, U::uo) is det,
+	pred add_list(list(T)::in, string::in,
+		pred(T, U, U)::pred(in, di, uo) is det,
+		U::di, U::uo) is det
+].
+
+:- instance output(io__state).
+:- instance output(string).
+
+% We use the following type class to share code between mercury_output_inst,
+% which outputs inst in Mercury syntax, and mercury_output_expanded_inst,
+% which is the same except that it expands any compiler-defined insts
+% (except those which have already been encountered).
+%
+% (XXX Perhaps we should use the same sort of technique to also avoid
+% code duplication with mercury_format_structured_inst.)
+
+:- typeclass inst_info(InstInfo) where [
+	(func instvarset(InstInfo) = inst_varset),
+	(pred format_defined_inst(inst_name::in, InstInfo::in,
+		U::di, U::uo) is det <= output(U))
+].
+
+:- type simple_inst_info
+	--->	simple_inst_info(sii_varset :: inst_varset).
+
+:- instance inst_info(simple_inst_info).
+
+%-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
 
 :- implementation.
 
-:- import_module backend_libs__foreign.
-:- import_module check_hlds__mode_util.
-:- import_module check_hlds__purity.
-:- import_module hlds__hlds_out.
-:- import_module hlds__hlds_pred.
-:- import_module hlds__instmap.
 :- import_module libs__globals.
 :- import_module libs__options.
 :- import_module parse_tree__prog_io_util.
@@ -386,7 +358,7 @@
 :- import_module parse_tree__prog_util.
 :- import_module recompilation__version.
 
-:- import_module assoc_list, char, int, string, set, lexer, ops, require.
+:- import_module assoc_list, int, string, set, lexer, ops, require.
 :- import_module term, term_io, varset.
 
 %-----------------------------------------------------------------------------%
@@ -1095,84 +1067,17 @@
 	mercury_format_tabs(Indent),
 	add_string("not_reached\n").
 
-% We use the following type class to share code between mercury_output_inst,
-% which outputs inst in Mercury syntax, and mercury_output_expanded_inst,
-% which is the same except that it expands any compiler-defined insts
-% (except those which have already been encountered).
-%
-% (XXX Perhaps we should use the same sort of technique to also avoid
-% code duplication with mercury_format_structured_inst.)
-
-:- typeclass inst_info(InstInfo) where [
-	(func instvarset(InstInfo) = inst_varset),
-	(pred format_defined_inst(inst_name::in, InstInfo::in,
-		U::di, U::uo) is det <= output(U))
-].
-
-:- type simple_inst_info
-	--->	simple_inst_info(sii_varset :: inst_varset).
-
 :- instance inst_info(simple_inst_info) where [
 	func(instvarset/1) is sii_varset,
 	pred(format_defined_inst/4) is mercury_format_inst_name
 ].
 
-:- instance inst_info(expanded_inst_info) where [
-	func(instvarset/1) is eii_varset,
-	pred(format_defined_inst/4) is mercury_format_expanded_defined_inst
-].
-
-:- type expanded_inst_info
-	--->	expanded_inst_info(
-			eii_varset :: inst_varset,
-			eii_module_info :: module_info,
-			eii_expansions :: set(inst_name)
-					% the set of already-expanded insts;
-					% further occurrences of these will
-					% be output as "..."
-		).
-
-:- pred mercury_format_expanded_defined_inst(inst_name::in,
-	expanded_inst_info::in, U::di, U::uo) is det <= output(U).
-
-mercury_format_expanded_defined_inst(InstName, ExpandedInstInfo) -->
-	( { set__member(InstName, ExpandedInstInfo ^ eii_expansions) } ->
-		add_string("...")
-	; { InstName = user_inst(_, _) } ->
-		% don't expand user-defined insts, just output them as is
-		% (we do expand any compiler-defined insts that occur
-		% in the arguments of the user-defined inst, however)
-		mercury_format_inst_name(InstName, ExpandedInstInfo)
-        ;
-                { inst_lookup(ExpandedInstInfo ^ eii_module_info, InstName,
-			Inst) },
-                { set__insert(ExpandedInstInfo ^ eii_expansions, InstName,
-			Expansions) },
-		mercury_format_inst(Inst,
-			ExpandedInstInfo ^ eii_expansions := Expansions)
-	).
-
-
-mercury_output_expanded_inst(Inst, VarSet, ModuleInfo) -->
-	{ set__init(Expansions) },
-	mercury_format_inst(Inst,
-		expanded_inst_info(VarSet, ModuleInfo, Expansions)).
-
-mercury_expanded_inst_to_string(Inst, VarSet, ModuleInfo) = String :-
-	set__init(Expansions),
-	mercury_format_inst(Inst,
-		expanded_inst_info(VarSet, ModuleInfo, Expansions),
-		"", String).
-
 mercury_output_inst(Inst, VarSet) -->
 	mercury_format_inst(Inst, simple_inst_info(VarSet)).
 
 mercury_inst_to_string(Inst, VarSet) = String :-
 	mercury_format_inst(Inst, simple_inst_info(VarSet), "", String).
 
-:- pred mercury_format_inst((inst)::in, InstInfo::in,
-	U::di, U::uo) is det <= (output(U), inst_info(InstInfo)).
-
 mercury_format_inst(any(Uniq), _) -->
 	mercury_format_any_uniqueness(Uniq).
 mercury_format_inst(free, _) -->
@@ -1357,9 +1262,6 @@
 	mercury_format_tabs(Indent),
 	add_string(")\n").
 
-:- pred mercury_format_inst_name(inst_name::in, InstInfo::in,
-	U::di, U::uo) is det <= (output(U), inst_info(InstInfo)).
-
 mercury_format_inst_name(user_inst(Name, Args), InstInfo) -->
 	( { Args = [] } ->
 		mercury_format_bracketed_sym_name(Name)
@@ -1542,12 +1444,10 @@
 	add_float(X).
 mercury_format_cons_id(string_const(X), _) -->
 	add_quoted_string(X).
-mercury_format_cons_id(pred_const(PredId, ProcId, EvalMethod), _) -->
+mercury_format_cons_id(pred_const(ShroudedPredProcId, EvalMethod), _) -->
 	% XXX Sufficient, but probably should print this out in
 	%     name/arity form.
-
-	{ pred_id_to_int(PredId, PredInt) },
-	{ proc_id_to_int(ProcId, ProcInt) },
+	{ ShroudedPredProcId = shrouded_pred_proc_id(PredInt, ProcInt) },
 	add_string("<pred_const("),
 	add_int(PredInt),
 	add_string(", "),
@@ -1576,7 +1476,7 @@
 	add_string("<type_info_cell_constructor>").
 mercury_format_cons_id(typeclass_info_cell_constructor, _) -->
 	add_string("<typeclass_info_cell_constructor>").
-mercury_format_cons_id(tabling_pointer_const(_, _), _) -->
+mercury_format_cons_id(tabling_pointer_const(_), _) -->
 	add_string("<tabling pointer>").
 mercury_format_cons_id(deep_profiling_proc_layout(_), _) -->
 	add_string("<deep_profiling_proc_layout>").
@@ -1630,48 +1530,12 @@
 		mercury_format_mode_list(Modes, InstInfo)
 	).
 
-mercury_output_uni_mode_list(UniModes, VarSet) -->
-	mercury_format_uni_mode_list(UniModes, VarSet).
-
-mercury_uni_mode_list_to_string(UniModes, VarSet) = String :-
-	mercury_format_uni_mode_list(UniModes, VarSet, "", String).
-
-:- pred mercury_format_uni_mode_list(list(uni_mode)::in, inst_varset::in,
-	U::di, U::uo) is det <= output(U).
-
-mercury_format_uni_mode_list([], _VarSet) --> [].
-mercury_format_uni_mode_list([Mode | Modes], VarSet) -->
-	mercury_format_uni_mode(Mode, VarSet),
-	( { Modes = [] } ->
-		[]
-	;
-		add_string(", "),
-		mercury_format_uni_mode_list(Modes, VarSet)
-	).
-
-mercury_output_uni_mode(UniMode, VarSet) -->
-	mercury_format_uni_mode(UniMode, VarSet).
-
-mercury_uni_mode_to_string(UniMode, VarSet) = String :-
-	mercury_format_uni_mode(UniMode, VarSet, "", String).
-
-:- pred mercury_format_uni_mode(uni_mode::in, inst_varset::in,
-	U::di, U::uo) is det <= output(U).
-
-mercury_format_uni_mode((InstA1 - InstB1 -> InstA2 - InstB2), VarSet) -->
-	mercury_format_mode((InstA1 -> InstA2), simple_inst_info(VarSet)),
-	add_string(" = "),
-	mercury_format_mode((InstB1 -> InstB2), simple_inst_info(VarSet)).
-
 mercury_output_mode(Mode, VarSet) -->
 	mercury_format_mode(Mode, simple_inst_info(VarSet)).
 
 mercury_mode_to_string(Mode, VarSet) = String :-
 	mercury_format_mode(Mode, simple_inst_info(VarSet), "", String).
 
-:- pred mercury_format_mode((mode)::in, InstInfo::in,
-	U::di, U::uo) is det <= (output(U), inst_info(InstInfo)).
-
 mercury_format_mode((InstA -> InstB), InstInfo) -->
 	(
 		%
@@ -1998,7 +1862,7 @@
 	),
 	add_purity_prefix(Purity),
 
-	{ PredOrFuncStr = hlds_out__pred_or_func_to_str(PredOrFunc) },
+	{ PredOrFuncStr = pred_or_func_to_str(PredOrFunc) },
 	add_string(PredOrFuncStr),
 	add_string(" "),
 
@@ -3153,7 +3017,7 @@
 mercury_output_pragma_unused_args(PredOrFunc, SymName,
 		Arity, ModeNum, UnusedArgs) -->
 	io__write_string(":- pragma unused_args("),
-	hlds_out__write_pred_or_func(PredOrFunc),
+	write_pred_or_func(PredOrFunc),
 	io__write_string(", "),
 	mercury_output_bracketed_sym_name(SymName),
 	io__write_string(", "),
@@ -3841,31 +3705,6 @@
 	unqualify_name(Name0, Name).
 
 %-----------------------------------------------------------------------------%
-
-% This is the typeclass mentioned in the long comment at the top of the module.
-
-:- 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,
-	pred add_int(int::in, U::di, U::uo) is det,
-	pred add_float(float::in, U::di, U::uo) is det,
-	pred add_purity_prefix(purity::in, U::di, U::uo) is det,
-	pred add_quoted_atom(string::in, U::di, U::uo) is det,
-	pred add_quoted_string(string::in, U::di, U::uo) is det,
-	pred add_constant(const::in, U::di, U::uo) is det,
-	pred add_class_id(class_id::in, U::di, U::uo) is det,
-	pred add_eval_method(eval_method::in, U::di, U::uo) is det,
-	pred add_lambda_eval_method(lambda_eval_method::in, U::di, U::uo)
-		is det,
-	pred add_index_type(index_type::in, U::di, U::uo) is det,
-	pred add_escaped_string(string::in, U::di, U::uo) is det,
-	pred add_format(string::in, list(io__poly_type)::in,
-		U::di, U::uo) is det,
-	pred add_list(list(T)::in, string::in,
-		pred(T, U, U)::pred(in, di, uo) is det,
-		U::di, U::uo) is det
-].
 
 :- instance output(io__state) where [
 	pred(add_string/3) is io__write_string,
Index: middle_rec.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/middle_rec.m,v
retrieving revision 1.99
diff -u -b -r1.99 middle_rec.m
Index: ml_closure_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_closure_gen.m,v
retrieving revision 1.27
diff -u -b -r1.27 ml_closure_gen.m
Index: ml_code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_code_gen.m,v
retrieving revision 1.140
diff -u -b -r1.140 ml_code_gen.m
Index: ml_code_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_code_util.m,v
retrieving revision 1.81
diff -u -b -r1.81 ml_code_util.m
--- ml_code_util.m	19 May 2004 03:59:28 -0000	1.81
+++ ml_code_util.m	12 Jun 2004 10:05:06 -0000
@@ -753,7 +753,6 @@
 :- import_module ml_backend__ml_call_gen.
 :- import_module ml_backend__ml_code_gen.
 :- import_module parse_tree__error_util.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__prog_data.
 :- import_module parse_tree__prog_io.
 :- import_module parse_tree__prog_util.
Index: ml_string_switch.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_string_switch.m,v
retrieving revision 1.16
diff -u -b -r1.16 ml_string_switch.m
Index: ml_unify_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_unify_gen.m,v
retrieving revision 1.75
diff -u -b -r1.75 ml_unify_gen.m
--- ml_unify_gen.m	19 May 2004 03:59:29 -0000	1.75
+++ ml_unify_gen.m	12 Jun 2004 10:05:06 -0000
@@ -431,11 +431,11 @@
 	DataAddr = data_addr(PredModule, tabling_pointer(PredLabel - ProcId)),
 	Rval = unop(cast(MLDS_VarType), const(data_addr_const(DataAddr))).
 
-ml_gen_constant(deep_profiling_proc_layout_tag(_), _, _, !Info) :-
+ml_gen_constant(deep_profiling_proc_layout_tag(_, _), _, _, !Info) :-
 	error("ml_gen_constant: " ++
 		"deep_profiling_proc_layout_tag not yet supported").
 
-ml_gen_constant(table_io_decl_tag(_), _, _, !Info) :-
+ml_gen_constant(table_io_decl_tag(_, _), _, _, !Info) :-
 	error("ml_gen_constant: table_io_decl_tag not yet supported").
 
 ml_gen_constant(reserved_address(ReservedAddr), VarType, Rval, !Info) :-
@@ -1325,10 +1325,10 @@
 		Tag = tabling_pointer_constant(_, _),
 		Statements = []
 	;
-		Tag = deep_profiling_proc_layout_tag(_),
+		Tag = deep_profiling_proc_layout_tag(_, _),
 		Statements = []
 	;
-		Tag = table_io_decl_tag(_),
+		Tag = table_io_decl_tag(_, _),
 		Statements = []
 	;
 		Tag = no_tag,
@@ -1443,10 +1443,10 @@
 		Tag = tabling_pointer_constant(_, _),
 		error("ml_tag_offset_and_argnum")
 	;
-		Tag = deep_profiling_proc_layout_tag(_),
+		Tag = deep_profiling_proc_layout_tag(_, _),
 		error("ml_tag_offset_and_argnum")
 	;
-		Tag = table_io_decl_tag(_),
+		Tag = table_io_decl_tag(_, _),
 		error("ml_tag_offset_and_argnum")
 	;
 		Tag = no_tag,
@@ -1459,7 +1459,6 @@
 		error("ml_tag_offset_and_argnum")
 	).
 
-
 	% Given a type and a cons_id, and also the types of the actual
 	% arguments of that cons_id in some particular use of it,
 	% look up the original types of the fields of that cons_id from
@@ -1761,10 +1760,10 @@
 ml_gen_tag_test_rval(tabling_pointer_constant(_, _), _, _, _) = _ :-
 	% This should never happen
 	error("Attempted tabling_pointer unification").
-ml_gen_tag_test_rval(deep_profiling_proc_layout_tag(_), _, _, _) = _ :-
+ml_gen_tag_test_rval(deep_profiling_proc_layout_tag(_, _), _, _, _) = _ :-
 	% This should never happen
 	error("Attempted deep_profiling_proc_layout unification").
-ml_gen_tag_test_rval(table_io_decl_tag(_), _, _, _) = _ :-
+ml_gen_tag_test_rval(table_io_decl_tag(_, _), _, _, _) = _ :-
 	% This should never happen
 	error("Attempted table_io_decl unification").
 ml_gen_tag_test_rval(no_tag, _, _, _Rval) = const(true).
Index: mlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds.m,v
retrieving revision 1.112
diff -u -b -r1.112 mlds.m
--- mlds.m	12 May 2004 14:24:29 -0000	1.112
+++ mlds.m	12 Jun 2004 10:05:07 -0000
@@ -1801,7 +1801,8 @@
 				% This is checked by check_foreign_type
 				% in make_hlds.
 				unexpected(this_file,
-				"mercury_type_to_mlds_type: No Java foreign type")
+					"mercury_type_to_mlds_type: " ++
+					"No Java foreign type")
 			)	
 		;
 			Target = asm,
Index: mlds_to_c.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_c.m,v
retrieving revision 1.163
diff -u -b -r1.163 mlds_to_c.m
Index: mlds_to_gcc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_gcc.m,v
retrieving revision 1.96
diff -u -b -r1.96 mlds_to_gcc.m
Index: mlds_to_il.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_il.m,v
retrieving revision 1.140
diff -u -b -r1.140 mlds_to_il.m
Index: mlds_to_ilasm.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_ilasm.m,v
retrieving revision 1.23
diff -u -b -r1.23 mlds_to_ilasm.m
Index: mlds_to_java.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_java.m,v
retrieving revision 1.59
diff -u -b -r1.59 mlds_to_java.m
Index: mlds_to_managed.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_managed.m,v
retrieving revision 1.12
diff -u -b -r1.12 mlds_to_managed.m
Index: mmc_analysis.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mmc_analysis.m,v
retrieving revision 1.3
diff -u -b -r1.3 mmc_analysis.m
--- mmc_analysis.m	5 Apr 2004 05:07:42 -0000	1.3
+++ mmc_analysis.m	12 Jun 2004 17:06:31 -0000
@@ -9,6 +9,7 @@
 % Specify Mercury compiler analyses to be used with the
 % inter-module analysis framework.
 %-----------------------------------------------------------------------------%
+
 :- module transform_hlds__mmc_analysis.
 
 :- interface.
@@ -62,4 +63,3 @@
 		- unqualified(Name)/Arity),
 	proc_id_to_int(ProcId, ProcInt),
 	FuncId = FuncId0 ++ "-" ++ int_to_string(ProcInt).
-
Index: mode_debug.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mode_debug.m,v
retrieving revision 1.16
diff -u -b -r1.16 mode_debug.m
--- mode_debug.m	6 Nov 2003 03:42:35 -0000	1.16
+++ mode_debug.m	12 Jun 2004 10:05:08 -0000
@@ -42,9 +42,9 @@
 :- import_module hlds__passes_aux.
 :- import_module libs__globals.
 :- import_module libs__options.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__mercury_to_mercury.
 :- import_module parse_tree__prog_data.
+:- import_module parse_tree__prog_out.
 
 :- import_module std_util, list, assoc_list, bool, map.
 :- import_module term, varset.
Index: mode_errors.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mode_errors.m,v
retrieving revision 1.78
diff -u -b -r1.78 mode_errors.m
--- mode_errors.m	5 Apr 2004 05:07:42 -0000	1.78
+++ mode_errors.m	12 Jun 2004 14:23:34 -0000
@@ -17,13 +17,11 @@
 
 :- interface.
 
-:- import_module hlds__hlds_data.
 :- import_module hlds__hlds_pred.
 :- import_module hlds__hlds_module.
 :- import_module hlds__hlds_goal.
 :- import_module parse_tree__prog_data.
 :- import_module check_hlds__mode_info.
-:- import_module parse_tree__inst.
 
 :- import_module bool, set, assoc_list, list, io.
 
@@ -189,11 +187,14 @@
 
 :- import_module check_hlds__mode_info.
 :- import_module check_hlds__mode_util.
+:- import_module hlds__hlds_data.
 :- import_module hlds__hlds_out.
 :- import_module libs__globals.
 :- import_module libs__options.
 :- import_module parse_tree__mercury_to_mercury.
+:- import_module parse_tree__prog_mode.
 :- import_module parse_tree__prog_out.
+:- import_module parse_tree__prog_util.
 
 :- import_module int, map, term_io, varset, term.
 :- import_module std_util, require.
@@ -443,7 +444,7 @@
 		prog_out__write_context(Context),
 		io__write_string("  inside the condition of an if-then-else.\n")
 	; { Reason = lambda(PredOrFunc) },
-		{ PredOrFuncS = hlds_out__pred_or_func_to_str(PredOrFunc) },
+		{ PredOrFuncS = pred_or_func_to_str(PredOrFunc) },
 		io__write_string("attempt to bind a non-local variable inside\n"),
 		prog_out__write_context(Context),
 		io__write_strings(["  a ", PredOrFuncS, " lambda goal.\n"])
@@ -752,11 +753,11 @@
 	globals__io_lookup_bool_option(verbose_errors, VerboseErrors),
 	( { VerboseErrors = yes } ->
 		io__write_string("\tYour code is trying to test whether two "),
-		hlds_out__write_pred_or_func(PredOrFunc),
+		write_pred_or_func(PredOrFunc),
 		io__write_string("s are equal,\n"),
 		io__write_string("\tby unifying them.  In the general case, testing equivalence\n"),
 		io__write_string("\tof "),
-		hlds_out__write_pred_or_func(PredOrFunc),
+		write_pred_or_func(PredOrFunc),
 		io__write_string("s is an undecidable problem,\n"),
 		io__write_string("\tand so this is not allowed by the Mercury mode system.\n"),
 		io__write_string("\tIn some cases, you can achieve the same effect by\n"),
Index: mode_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mode_info.m,v
retrieving revision 1.64
diff -u -b -r1.64 mode_info.m
--- mode_info.m	6 Nov 2003 03:42:35 -0000	1.64
+++ mode_info.m	12 Jun 2004 10:05:08 -0000
@@ -23,7 +23,6 @@
 :- import_module hlds__hlds_module.
 :- import_module hlds__hlds_pred.
 :- import_module hlds__instmap.
-:- import_module parse_tree__inst.
 :- import_module parse_tree__prog_data.
 
 :- import_module map, list, set, bool, assoc_list, std_util.
--------------------------------------------------------------------------
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