[m-rev.] diff: more :- import_module updates, and tree.m

Zoltan Somogyi zs at cs.mu.OZ.AU
Thu Mar 24 12:55:59 AEDT 2005


compiler/*.m:
	Import only one module per line in the modules of the compiler
	where my previous diff did not already do so.

	Misc other cleanups.

	Where relevant, use the new mechanism in tree.m.

compiler/tree.m:
	Fix a performance problem I noticed while update :- import_module
	items. Instead of supplying a function to convert lists of trees
	to a tree, make the tree data structure able to hold a list of
	subtrees directly. This reduces the number of times where we have to
	convert list of trees to trees that are sticks just to stay within
	the old definition of what a tree is.

Zoltan.

cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/abstract_mode_constraints.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/abstract_mode_constraints.m,v
retrieving revision 1.2
diff -u -b -r1.2 abstract_mode_constraints.m
--- compiler/abstract_mode_constraints.m	25 Feb 2005 12:13:04 -0000	1.2
+++ compiler/abstract_mode_constraints.m	19 Mar 2005 02:44:19 -0000
@@ -30,12 +30,8 @@
 %-----------------------------------------------------------------------------%
 
 :- type mc_type.
-
 :- type mc_var == var(mc_type).		% Constraint variable.
-
-:- type mc_varset == varset(mc_type).	% Source of constraint variables
-					% And their names.
-:- type vars(T) == list(var(T)).
+:- type mc_varset == varset(mc_type).	% Source of constraint variables.
 
 %-----------------------------------------------------------------------------%
 %
@@ -64,11 +60,9 @@
 			% other constraints.  The intended form is:
 			% disj([conj(...), ..., conj(...)]) Note
 			% disj([]) represents false.
-	;	conj(constraint_formulae)
+	;	conj(constraint_formulae).
 			% See disj.
 			% Note that conj([]) is the empty constraint, or true.
-.
-
 
 % var_constraint represents a constraint between variables
 :- type var_constraint == var_constraint(mc_type).
@@ -76,21 +70,21 @@
 	--->	equiv_bool(var(T), bool)
 			% equiv_bool(X, yes) gives the constraint (X)
 			% equiv_bool(X, no) gives the constraint not(X)
-	;	equivalent(vars(T))
+	;	equivalent(list(var(T)))
 			% equivalent(Xs) gives (all Xi, Xj in Xs).(Xi<->Xj)
 	;	implies(var(T), var(T))
 			% implies(X, Y) gives X->Y
-	;	equiv_disj(var(T), vars(T))
+	;	equiv_disj(var(T), list(var(T)))
 			% equiv_disj(X, [Y1,...,Yn]) gives X<->OR(Y1,...,Yn)
 			% XXX Thinking of making a constraint that is
 			% the conjunction of equiv_disj and at_most_one
 			% because they occur together so often.
-	;	at_most_one(vars(T))
+	;	at_most_one(list(var(T)))
 			% at_most_one(Xs) gives
 			% (all Xi, Xj in Xs).(i = j or not(Xi and Xj))
-	;	at_least_one(vars(T))
+	;	at_least_one(list(var(T)))
 			% at_least_one(Xs) gives OR(Xs)
-	;	exactly_one(vars(T)).
+	;	exactly_one(list(var(T))).
 			% exactly_one(Xs) gives
 			% at_least_one(Xs) and at_most_one(Xs)
 
@@ -143,8 +137,11 @@
 	mode_constraints_info(
 		constraint_map	:: map(constraint_id, constraint),
 			% Constraining the variables in the var_map.
+
 		var_map		:: map(mc_var, var_state),
-			% The variables this constraint system constrains
+				% The variables this constraint system
+				% constrains.
+
 		id_counter	:: counter
 			% Supplies unique IDs for the constraint map.
 	).
@@ -154,18 +151,21 @@
 :- type constraint --->
 	constraint(
 		id		:: constraint_id,
+
 		current		:: constraint_formula_and_vars,
 			% Formula modified as variables are bound.
+
 		original	:: constraint_formula_and_vars
+
 %		dead		:: bool
-%			% for if the current constraint is empty... don't
-%			% know if this will be used
+%				% For if the current constraint is empty...
+%				% don't know if this will be used.
 	).
 
 :- type constraint_formula_and_vars --->
 	constraint_formula_and_vars(
 		constraint_formula	:: constraint_formula,
-		participating_vars	:: vars(mc_type)
+		participating_vars	:: list(mc_var)
 	).
 
 :- type var_state --->
@@ -173,6 +173,7 @@
 		is_bound	:: maybe(var_binding),
 			% If it is bound, some certain information
 			% should be recorded. See var_binding type.
+
 		is_constrained	:: list(constrainment_info)
 			% A list of the constraints that this variable
 			% participates in. May include propagation tree
@@ -184,29 +185,38 @@
 :- type var_binding --->
 	var_binding(
 		bool			:: bool,
-			% What the variable has been bound to
+					% What the variable has been bound to.
+
 		binding_constraint	:: constraint_id,
-			% The constraint that finally bound it
+					% The constraint that finally bound it.
+
 		history			:: list(mc_var)
-			% The variables in the constraint that bound
-			% this variable that had already been bound at
-			% that point - their binding_constraint and
-			% history can be looked at recursively to build
-			% the full history. I strongly prefer this to
-			% listing the full history each time a variable
-			% is bound, for space considerations.
+					% The variables in the constraint
+					% that bound this variable that
+					% had already been bound at that
+					% point - their binding_constraint
+					% and history can be looked at
+					% recursively to build the full
+					% history. I strongly prefer this
+					% to listing the full history
+					% each time a variable is bound,
+					% for space considerations.
 	).
 
 :- type constrainment_info --->
 	constrainment_info(
 %		variable		:: mc_var,
-%			% To make it clear what variable the propagation
-%			% information is for.
+%					% To make it clear what variable
+%					% the propagation information is for.
+%
 %		propagate_if_true	:: list(var_binding),
-%			% The history field should be empty. In the end it
-%			% gets the participating variables of this constraint
-%			% that have been bound.
+%					% The history field should be empty.
+%					% In the end it gets the participating
+%					% variables of this constraint that
+%					% have been bound.
+%
 %		propagate_if_false	:: list(var_binding),
+
 		constraint		:: constraint_id
 	).
 
@@ -241,11 +251,9 @@
 	% Initiates all the parts of a mode_constraints_info type.
 	%
 abstract_mode_constraints.init(ModeConstraintsInfo) :-
-	ModeConstraintsInfo = mode_constraints_info(
-		map.init,
-		map.init,
-		counter.init(0)		% Start allocating ids from 0
-	).
+		% Start allocating ids from 0
+	ModeConstraintsInfo = mode_constraints_info(map.init, map.init,
+		counter.init(0)).
 
 	% See the predicate version.
 	%
@@ -256,18 +264,18 @@
 	%
 abstract_mode_constraints.add_constraint(ConstraintFormula,
 		!ModeConstraintsInfo) :-
-	formula_to_formula_and_vars(ConstraintFormula, 
-		Vars, FormulaAndVars),
+	formula_to_formula_and_vars(ConstraintFormula, Vars, FormulaAndVars),
 	counter.allocate(NewID, !.ModeConstraintsInfo ^ id_counter,
 		NewCounter),
 	!:ModeConstraintsInfo =
 		!.ModeConstraintsInfo ^ id_counter := NewCounter,
 	update_vars_map_with_constrainment_info(constrainment_info(NewID),
 		Vars, !ModeConstraintsInfo),
+	Constraint = constraint(NewID, FormulaAndVars, FormulaAndVars),
+	ConstraintMap0 = !.ModeConstraintsInfo ^ constraint_map,
+	map.det_insert(ConstraintMap0, NewID, Constraint, ConstraintMap),
 	!:ModeConstraintsInfo = !.ModeConstraintsInfo ^ constraint_map :=
-		map.det_insert(!.ModeConstraintsInfo ^ constraint_map,
-			NewID, 
-			constraint(NewID, FormulaAndVars, FormulaAndVars)).
+		ConstraintMap.
 	
 	% Functional version of add_constraint/3.
 	%
@@ -278,40 +286,40 @@
 % constrainment_info to the list of constraints associated with each of
 % the variables supplied in the mode_constraints_info structure.
 
-:- pred update_vars_map_with_constrainment_info(
-	constrainment_info::in, vars(mc_type)::in,
-	mode_constraints_info::in, mode_constraints_info::out
-	) is det.
+:- pred update_vars_map_with_constrainment_info(constrainment_info::in,
+	list(mc_var)::in,
+	mode_constraints_info::in, mode_constraints_info::out) is det.
 
 update_vars_map_with_constrainment_info(_ConstrainmentInfo, [], !MCI).
-update_vars_map_with_constrainment_info(ConstrainmentInfo, [Var|Vars], !MCI) :-
-	(	map.search(!.MCI ^ var_map, Var, VarState1)
-	->	CInfoList = [ConstrainmentInfo| VarState1 ^ is_constrained],
-		VarState = VarState1 ^ is_constrained := CInfoList,
+update_vars_map_with_constrainment_info(ConstrainmentInfo, [Var | Vars],
+		!MCI) :-
+	( map.search(!.MCI ^ var_map, Var, OldVarState) ->
+		CInfoList = [ConstrainmentInfo | OldVarState ^ is_constrained],
+		VarState = OldVarState ^ is_constrained := CInfoList,
 		!:MCI = !.MCI ^ var_map :=
 			map.det_update(!.MCI ^ var_map, Var, VarState)
-	;	VarState = var_state(no, [ConstrainmentInfo]),
+	;
+		VarState = var_state(no, [ConstrainmentInfo]),
 		!:MCI = !.MCI ^ var_map :=
 			map.det_insert(!.MCI ^ var_map, Var, VarState)
 	),
 	update_vars_map_with_constrainment_info(ConstrainmentInfo, Vars, !MCI).
 
-% formula_to_formula_and_vars makes the list Vars of variables that
-% appear in Formula and packages Formula and Vars together in
-% FormulaAndVars.
-:- pred formula_to_formula_and_vars(
-	constraint_formula::in,
-	vars(mc_type)::out,
-	constraint_formula_and_vars::out
-	) is det.
+	% formula_to_formula_and_vars makes the list Vars of variables that
+	% appear in Formula and packages Formula and Vars together in
+	% FormulaAndVars.
+	%
+:- pred formula_to_formula_and_vars(constraint_formula::in, list(mc_var)::out,
+	constraint_formula_and_vars::out) is det.
 
 formula_to_formula_and_vars(Formula, Vars, FormulaAndVars) :-
 	formula_to_vars(Formula, Vars),
 	FormulaAndVars = constraint_formula_and_vars(Formula, Vars).
 
-% Sub section of the formula_to_formula_and_vars predicate, Vars is the
-% variables that appear in Formula
-:- pred formula_to_vars(constraint_formula::in, vars(mc_type)::out) is det.
+	% Sub section of the formula_to_formula_and_vars predicate, Vars is the
+	% variables that appear in Formula.
+	%
+:- pred formula_to_vars(constraint_formula::in, list(mc_var)::out) is det.
 
 formula_to_vars(Formula, Vars) :-
 	Formula = atomic_constraint(VarConstraint),
@@ -323,30 +331,27 @@
 			formula_to_vars(Formula1, Vars2),
 			append(Vars2, Vars1, VarsNew)
 		),
-		Formulae,
-		[],
-		Vars
-	).
+		Formulae, [], Vars).
 formula_to_vars(Formula, Vars) :-
 	Formula = conj(Formulae),
-	list.foldr(
-		(pred(Formula1::in, Vars1::in, VarsNew::out) is det :-
-			formula_to_vars(Formula1, Vars2),
-			append(Vars2, Vars1, VarsNew)
-		),
-		Formulae,
-		[],
-		Vars
-	).
+	list.foldr(formula_to_vars_accumulate, Formulae, [], Vars).
+
+:- pred formula_to_vars_accumulate(constraint_formula::in,
+	list(mc_var)::in, list(mc_var)::out) is det.
 
-% var_constraint_to_vars takes a constraint between variables as input
-% and gives a list of those variables as output.
-:- pred var_constraint_to_vars(var_constraint::in, vars(mc_type)::out) is det.
+formula_to_vars_accumulate(Formula, !Vars) :-
+	formula_to_vars(Formula, NewVars),
+	append(NewVars, !Vars).
+
+	% var_constraint_to_vars takes a constraint between variables as input
+	% and gives a list of those variables as output.
+	%
+:- pred var_constraint_to_vars(var_constraint::in, list(mc_var)::out) is det.
 
 var_constraint_to_vars(equiv_bool(Var, _B), [Var]).
 var_constraint_to_vars(equivalent(Vars), Vars).
 var_constraint_to_vars(implies(V1, V2), [V1, V2]).
-var_constraint_to_vars(equiv_disj(Var, Vars), [Var|Vars]).
+var_constraint_to_vars(equiv_disj(Var, Vars), [Var | Vars]).
 var_constraint_to_vars(at_most_one(Vars), Vars).
 var_constraint_to_vars(at_least_one(Vars), Vars).
 var_constraint_to_vars(exactly_one(Vars), Vars).
@@ -369,12 +374,8 @@
 %
 
 pretty_print_constraints(Varset, Constraints, !IO) :-
-	pretty_print_constraints(
-		Varset,
-		Constraints,
-		"",		% Extra argument for indent.
-		!IO
-	).
+	Indent = "",
+	pretty_print_constraints(Varset, Constraints, Indent, !IO).
 
 	% Same as before, but with an indent argument used to indent
 	% conjunctions and disjunctions of constraints.
@@ -383,7 +384,7 @@
 	string::in, io::di, io::uo) is det.
 
 pretty_print_constraints(_Varset, [], _Indent, !IO).
-pretty_print_constraints(Varset, [Constr|Constrs], Indent, !IO) :-
+pretty_print_constraints(Varset, [Constr | Constrs], Indent, !IO) :-
 	pretty_print_constraint(Varset, Constr, Indent, !IO),
 	pretty_print_constraints(Varset, Constrs, Indent, !IO).
 
@@ -396,8 +397,7 @@
 pretty_print_constraint(Varset, disj(Constraints), Indent, !IO) :-
 	io.print(Indent, !IO),
 	io.print("disj(\n", !IO),
-	pretty_print_constraints(
-		Varset, Constraints, "\t" ++ Indent, !IO),
+	pretty_print_constraints(Varset, Constraints, "\t" ++ Indent, !IO),
 	io.print(Indent, !IO),
 	io.print(") end disj", !IO),
 	io.nl(!IO).
@@ -405,14 +405,12 @@
 pretty_print_constraint(Varset, conj(Constraints), Indent, !IO) :-
 	io.print(Indent, !IO),
 	io.print("conj(\n", !IO),
-	pretty_print_constraints(
-		Varset, Constraints, "\t" ++ Indent, !IO),
+	pretty_print_constraints(Varset, Constraints, "\t" ++ Indent, !IO),
 	io.print(Indent, !IO),
 	io.print(") end conj", !IO),
 	io.nl(!IO).
 
-pretty_print_constraint(
-	Varset, atomic_constraint(Constraint), Indent, !IO) :-
+pretty_print_constraint(Varset, atomic_constraint(Constraint), Indent, !IO) :-
 	io.print(Indent, !IO),
 	pretty_print_var_constraint(Varset, Constraint, !IO),
 	io.nl(!IO).
@@ -475,7 +473,7 @@
 	io::di, io::uo) is det.
 
 pretty_print_mc_vars(_Varset, [], !IO).
-pretty_print_mc_vars(Varset, [Var| Tail], !IO) :-
+pretty_print_mc_vars(Varset, [Var | Tail], !IO) :-
 	pretty_print_mc_var(Varset, Var, !IO),
 	pretty_print_mc_vars_tail(Varset, Tail, !IO).
 
@@ -488,9 +486,9 @@
 	io::di, io::uo) is det.
 
 pretty_print_mc_vars_tail(_Varset, [], !IO).
-pretty_print_mc_vars_tail(Varset, [Var| Vars], !IO) :-
+pretty_print_mc_vars_tail(Varset, [Var | Vars], !IO) :-
 	io.print(", ", !IO),
-	pretty_print_mc_vars(Varset, [Var| Vars], !IO).
+	pretty_print_mc_vars(Varset, [Var | Vars], !IO).
 
 %-----------------------------------------------------------------------------%
 :- end_module abstract_mode_constraints.
Index: compiler/accumulator.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/accumulator.m,v
retrieving revision 1.36
diff -u -b -r1.36 accumulator.m
--- compiler/accumulator.m	21 Jan 2005 06:20:34 -0000	1.36
+++ compiler/accumulator.m	19 Mar 2005 01:31:49 -0000
@@ -146,6 +146,7 @@
 
 :- import_module hlds__hlds_module.
 :- import_module hlds__hlds_pred.
+
 :- import_module io.
 
 :- pred accumulator__process_proc(pred_id::in, proc_id::in,
@@ -175,8 +176,18 @@
 :- import_module parse_tree__prog_util.
 :- import_module transform_hlds__goal_store.
 
-:- import_module assoc_list, bool, int, list, map, multi_map.
-:- import_module require, set, std_util, string, term, varset.
+:- import_module assoc_list.
+:- import_module bool.
+:- import_module int.
+:- import_module list.
+:- import_module map.
+:- import_module multi_map.
+:- import_module require.
+:- import_module set.
+:- import_module std_util.
+:- import_module string.
+:- import_module term.
+:- import_module varset.
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/add_heap_ops.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_heap_ops.m,v
retrieving revision 1.15
diff -u -b -r1.15 add_heap_ops.m
--- compiler/add_heap_ops.m	19 Jan 2005 03:10:28 -0000	1.15
+++ compiler/add_heap_ops.m	19 Mar 2005 01:32:13 -0000
@@ -52,8 +52,16 @@
 :- import_module parse_tree__prog_data.
 :- import_module parse_tree__prog_util.
 
-:- import_module bool, string.
-:- import_module assoc_list, list, map, set, varset, std_util, require, term.
+:- import_module assoc_list.
+:- import_module bool.
+:- import_module list.
+:- import_module map.
+:- import_module require.
+:- import_module set.
+:- import_module std_util.
+:- import_module string.
+:- import_module term.
+:- import_module varset.
 
 %
 % As we traverse the goal, we add new variables to hold the
Index: compiler/add_trail_ops.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_trail_ops.m,v
retrieving revision 1.17
diff -u -b -r1.17 add_trail_ops.m
--- compiler/add_trail_ops.m	19 Jan 2005 03:10:28 -0000	1.17
+++ compiler/add_trail_ops.m	19 Mar 2005 01:32:32 -0000
@@ -51,8 +51,16 @@
 :- import_module parse_tree__prog_data.
 :- import_module parse_tree__prog_util.
 
-:- import_module bool, string.
-:- import_module assoc_list, list, map, set, varset, std_util, require, term.
+:- import_module assoc_list.
+:- import_module bool.
+:- import_module list.
+:- import_module map.
+:- import_module require.
+:- import_module set.
+:- import_module std_util.
+:- import_module string.
+:- import_module term.
+:- import_module varset.
 
 %
 % As we traverse the goal, we add new variables to hold the
Index: compiler/aditi_builtin_ops.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/aditi_builtin_ops.m,v
retrieving revision 1.13
diff -u -b -r1.13 aditi_builtin_ops.m
--- compiler/aditi_builtin_ops.m	21 Jan 2005 03:27:34 -0000	1.13
+++ compiler/aditi_builtin_ops.m	19 Mar 2005 01:32:45 -0000
@@ -3,6 +3,7 @@
 % This file may only be copied under the terms of the GNU General
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
+%
 % File: aditi_builtin_ops.m
 % Main author: stayl
 %
@@ -16,6 +17,7 @@
 
 :- import_module hlds__hlds_module.
 :- import_module hlds__hlds_pred.
+
 :- import_module io.
 
 	% Transform Aditi builtin generic_call goals into calls to
Index: compiler/arg_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/arg_info.m,v
retrieving revision 1.43
diff -u -b -r1.43 arg_info.m
--- compiler/arg_info.m	14 Jun 2004 04:15:56 -0000	1.43
+++ compiler/arg_info.m	19 Mar 2005 02:07:40 -0000
@@ -23,7 +23,9 @@
 :- import_module hlds__hlds_pred.
 :- import_module parse_tree__prog_data.
 
-:- import_module list, assoc_list, set.
+:- import_module assoc_list.
+:- import_module list.
+:- import_module set.
 
 	% Annotate every non-aditi procedure in the module with information
 	% about its argument passing interface.
@@ -96,7 +98,11 @@
 
 :- import_module check_hlds__mode_util.
 
-:- import_module std_util, map, int, require.
+:- import_module std_util.
+:- import_module map.
+:- import_module int.
+:- import_module require.
+:- import_module svset.
 
 %-----------------------------------------------------------------------------%
 
@@ -122,8 +128,7 @@
 	module_info::in, module_info::out) is det.
 
 generate_proc_list_arg_info(_PredId, [], !ModuleInfo).
-generate_proc_list_arg_info(PredId, [ProcId | ProcIds],
-		!ModuleInfo) :-
+generate_proc_list_arg_info(PredId, [ProcId | ProcIds], !ModuleInfo) :-
 	module_info_preds(!.ModuleInfo, PredTable0),
 	map__lookup(PredTable0, PredId, PredInfo0),
 	( hlds_pred__pred_info_is_aditi_relation(PredInfo0) ->
@@ -186,20 +191,18 @@
 	module_info::in, list(arg_info)::out) is det.
 
 make_arg_infos_list([], [], _, _, _, []).
-make_arg_infos_list([Mode | Modes], [Type | Types], InReg0, OutReg0,
+make_arg_infos_list([Mode | Modes], [Type | Types], !.InReg, !.OutReg,
 		ModuleInfo, [ArgInfo | ArgInfos]) :-
 	mode_to_arg_mode(ModuleInfo, Mode, Type, ArgMode),
 	( ArgMode = top_in ->
-		ArgReg = InReg0,
-		InReg1 = InReg0 + 1,
-		OutReg1 = OutReg0
-	;
-		ArgReg = OutReg0,
-		InReg1 = InReg0,
-		OutReg1 = OutReg0 + 1
+		ArgReg = !.InReg,
+		!:InReg = !.InReg + 1
+	;
+		ArgReg = !.OutReg,
+		!:OutReg = !.OutReg + 1
 	),
 	ArgInfo = arg_info(ArgReg, ArgMode),
-	make_arg_infos_list(Modes, Types, InReg1, OutReg1,
+	make_arg_infos_list(Modes, Types, !.InReg, !.OutReg,
 		ModuleInfo, ArgInfos).
 make_arg_infos_list([], [_|_], _, _, _, _) :-
 	error("make_arg_infos_list: length mis-match").
@@ -209,13 +212,12 @@
 %---------------------------------------------------------------------------%
 
 arg_info__compute_in_and_out_vars(ModuleInfo, Vars, Modes, Types,
-		InVars, OutVars) :-
+		!:InVars, !:OutVars) :-
 	(
 		arg_info__compute_in_and_out_vars_2(ModuleInfo,
-			Vars, Modes, Types, InVars1, OutVars1)
+			Vars, Modes, Types, !:InVars, !:OutVars)
 	->
-		InVars = InVars1,
-		OutVars = OutVars1
+		true
 	;
 		error("arg_info__compute_in_and_out_vars: length mismatch")
 	).
@@ -226,16 +228,14 @@
 
 arg_info__compute_in_and_out_vars_2(_ModuleInfo, [], [], [], [], []).
 arg_info__compute_in_and_out_vars_2(ModuleInfo, [Var | Vars],
-		[Mode | Modes], [Type | Types], InVars, OutVars) :-
+		[Mode | Modes], [Type | Types], !:InVars, !:OutVars) :-
 	arg_info__compute_in_and_out_vars_2(ModuleInfo, Vars,
-		Modes, Types, InVars1, OutVars1),
+		Modes, Types, !:InVars, !:OutVars),
 	mode_to_arg_mode(ModuleInfo, Mode, Type, ArgMode),
 	( ArgMode = top_in ->
-		InVars = [Var | InVars1],
-		OutVars = OutVars1
+		!:InVars = [Var | !.InVars]
 	;
-		InVars = InVars1,
-		OutVars = [Var | OutVars1]
+		!:OutVars = [Var | !.OutVars]
 	).
 
 %---------------------------------------------------------------------------%
@@ -254,24 +254,18 @@
 	list__append(Outs0, Unuseds, Outs).
 
 arg_info__partition_args([], [], [], []).
-arg_info__partition_args([Var - ArgInfo | Rest], Ins, Outs, Unuseds) :-
-	arg_info__partition_args(Rest, Ins0, Outs0, Unuseds0),
+arg_info__partition_args([Var - ArgInfo | Rest], !:Ins, !:Outs, !:Unuseds) :-
+	arg_info__partition_args(Rest, !:Ins, !:Outs, !:Unuseds),
 	ArgInfo = arg_info(_, ArgMode),
 	(
 		ArgMode = top_in,
-		Ins = [Var - ArgInfo | Ins0],
-		Outs = Outs0,
-		Unuseds = Unuseds0
+		!:Ins = [Var - ArgInfo | !.Ins]
 	;
 		ArgMode = top_out,
-		Ins = Ins0,
-		Outs = [Var - ArgInfo | Outs0],
-		Unuseds = Unuseds0
+		!:Outs = [Var - ArgInfo | !.Outs]
 	;
 		ArgMode = top_unused,
-		Ins = Ins0,
-		Outs = Outs0,
-		Unuseds = [Var - ArgInfo | Unuseds0]
+		!:Unuseds = [Var - ArgInfo | !.Unuseds]
 	).
 
 %---------------------------------------------------------------------------%
@@ -279,12 +273,12 @@
 :- pred arg_info__input_args(list(arg_info)::in, list(arg_loc)::out) is det.
 
 arg_info__input_args([], []).
-arg_info__input_args([arg_info(Loc, Mode) | Args], Vs) :-
-	arg_info__input_args(Args, Vs0),
+arg_info__input_args([arg_info(Loc, Mode) | Args], !:Locs) :-
+	arg_info__input_args(Args, !:Locs),
 	( Mode = top_in ->
-		Vs = [Loc | Vs0]
+		!:Locs = [Loc | !.Locs]
 	;
-		Vs = Vs0
+		true
 	).
 
 %---------------------------------------------------------------------------%
@@ -314,15 +308,13 @@
 	set(prog_var)::out, set(prog_var)::out) is det.
 
 arg_info__do_partition_proc_args(ModuleInfo, Vars, Types, Modes,
-		Inputs, Outputs, Unuseds) :-
+		!:Inputs, !:Outputs, !:Unuseds) :-
 	(
 		arg_info__partition_proc_args_2(Vars, Types, Modes, ModuleInfo,
-			set__init, Inputs1, set__init, Outputs1,
-			set__init, Unuseds1)
+			set__init, !:Inputs, set__init, !:Outputs,
+			set__init, !:Unuseds)
 	->
-		Inputs = Inputs1,
-		Outputs = Outputs1,
-		Unuseds = Unuseds1
+		true
 	;
 		error("arg_info__do_partition_proc_args: list length mismatch")
 	).
@@ -334,26 +326,19 @@
 	set(prog_var)::in, set(prog_var)::out) is semidet.
 
 arg_info__partition_proc_args_2([], [], [], _ModuleInfo,
-		Inputs, Inputs, Outputs, Outputs, Unuseds, Unuseds).
+		!Inputs, !Outputs, !Unuseds).
 arg_info__partition_proc_args_2([Var | Vars], [Type | Types], [Mode | Modes],
-		ModuleInfo, Inputs0, Inputs, Outputs0, Outputs,
-		Unuseds0, Unuseds) :-
+		ModuleInfo, !Inputs, !Outputs, !Unuseds) :-
 	mode_to_arg_mode(ModuleInfo, Mode, Type, ArgMode),
 	(
 		ArgMode = top_in,
-		set__insert(Inputs0, Var, Inputs1),
-		Outputs1 = Outputs0,
-		Unuseds1 = Unuseds0
+		svset__insert(Var, !Inputs)
 	;
 		ArgMode = top_out,
-		Inputs1 = Inputs0,
-		set__insert(Outputs0, Var, Outputs1),
-		Unuseds1 = Unuseds0
+		svset__insert(Var, !Outputs)
 	;
 		ArgMode = top_unused,
-		Inputs1 = Inputs0,
-		Outputs1 = Outputs0,
-		set__insert(Unuseds0, Var, Unuseds1)
+		svset__insert(Var, !Unuseds)
 	),
 	arg_info__partition_proc_args_2(Vars, Types, Modes, ModuleInfo,
-		Inputs1, Inputs, Outputs1, Outputs, Unuseds1, Unuseds).
+		!Inputs, !Outputs, !Unuseds).
Index: compiler/assertion.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/assertion.m,v
retrieving revision 1.33
diff -u -b -r1.33 assertion.m
--- compiler/assertion.m	21 Jan 2005 06:20:35 -0000	1.33
+++ compiler/assertion.m	19 Mar 2005 01:38:01 -0000
@@ -24,7 +24,8 @@
 :- import_module hlds__hlds_pred.
 :- import_module parse_tree__prog_data.
 
-:- import_module io, std_util.
+:- import_module io.
+:- import_module std_util.
 
 	%
 	% assertion__goal
@@ -154,7 +155,14 @@
 :- import_module parse_tree__prog_util.
 :- import_module parse_tree__prog_type.
 
-:- import_module string, bool, list, assoc_list, map, set, require, std_util.
+:- import_module assoc_list.
+:- import_module bool.
+:- import_module list.
+:- import_module map.
+:- import_module require.
+:- import_module set.
+:- import_module std_util.
+:- import_module string.
 
 :- type subst == map(prog_var, prog_var).
 
Index: compiler/atsort.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/atsort.m,v
retrieving revision 1.13
diff -u -b -r1.13 atsort.m
--- compiler/atsort.m	5 Apr 2004 05:06:45 -0000	1.13
+++ compiler/atsort.m	19 Mar 2005 03:53:18 -0000
@@ -14,7 +14,9 @@
 :- module libs__atsort.
 
 :- interface.
-:- import_module map, list.
+
+:- import_module list.
+:- import_module map.
 
 :- type relmap(T) == map(T, list(T)).
 
@@ -42,6 +44,7 @@
 %-----------------------------------------------------------------------------%
 
 :- implementation.
+
 :- import_module require.
 
 % :- pred main1(list(list(int))).
@@ -82,16 +85,15 @@
 :- pred atsort__main(list(T)::in, relmap(T)::in, relmap(T)::in,
 	relmap(T)::in, relmap(T)::in, list(T)::in, list(list(T))::out) is det.
 
-atsort__main(Nodes0, Succmap0, Predmap0, MustSuccmap, MustPredmap, PrefOrder,
+atsort__main(Nodes0, !.Succmap, !.Predmap, MustSuccmap, MustPredmap, PrefOrder,
 		Sorted) :-
-	atsort__repeat_source_sink(Nodes0,
-		Succmap0, Succmap1, Predmap0, Predmap1,
+	atsort__repeat_source_sink(Nodes0, !Succmap, !Predmap,
 		[], Source1, Mid1, [], Sink1),
 	( Mid1 = [] ->
 		list__reverse(Source1, Source1rev),
 		list__append(Source1rev, Sink1, Sorted)
 	;
-		atsort__choose(Mid1, Succmap1, Succmap2, Predmap1, Predmap2,
+		atsort__choose(Mid1, !Succmap, !Predmap,
 			MustSuccmap, MustPredmap, PrefOrder, Chosen, Mid2),
 		% write('Chosen: '),
 		% write(Chosen),
@@ -99,8 +101,8 @@
 		% write('Not chosen: '),
 		% write(Mid2),
 		% nl,
-		atsort__main(Mid2, Succmap2, Predmap2, MustSuccmap, MustPredmap,
-			PrefOrder, MidSorted),
+		atsort__main(Mid2, !.Succmap, !.Predmap,
+			MustSuccmap, MustPredmap, PrefOrder, MidSorted),
 		list__reverse(Source1, Source1rev),
 		list__condense([Source1rev, [[Chosen]], MidSorted, Sink1],
 			Sorted)
@@ -113,17 +115,17 @@
 	relmap(T)::in, relmap(T)::in, list(T)::in, T::out, list(T)::out)
 	is det.
 
-atsort__choose(Nodes, Succmap0, Succmap, Predmap0, Predmap,
-		_MustSuccmap, MustPredmap, PrefOrder, Chosen, NotChosen) :-
+atsort__choose(Nodes, !Succmap, !Predmap, _MustSuccmap, MustPredmap, PrefOrder,
+		Chosen, NotChosen) :-
 	atsort__can_choose(Nodes, Nodes, MustPredmap, [], CanChoose),
 	atsort__choose_pref(PrefOrder, CanChoose, Chosen),
 	list__delete_all(Nodes, Chosen, NotChosen),
-	atsort__map_delete_all_source_links([Chosen],
-		Succmap0, Predmap0, Predmap1),
-	atsort__map_delete_all_sink_links([Chosen],
-		Predmap0, Succmap0, Succmap1),
-	atsort__map_delete_all_nodes([Chosen], Succmap1, Succmap),
-	atsort__map_delete_all_nodes([Chosen], Predmap1, Predmap).
+	Succmap0 = !.Succmap,
+	Predmap0 = !.Predmap,
+	atsort__map_delete_all_source_links([Chosen], Succmap0, !Predmap),
+	atsort__map_delete_all_sink_links([Chosen], Predmap0, !Succmap),
+	atsort__map_delete_all_nodes([Chosen], !Succmap),
+	atsort__map_delete_all_nodes([Chosen], !Predmap).
 
 	% See whether this node can be chosen ahead of the given list of nodes.
 	% Do not give preference to nodes that occur in MustPredmap.
@@ -131,18 +133,18 @@
 :- pred atsort__can_choose(list(T)::in, list(T)::in, relmap(T)::in,
 	list(T)::in, list(T)::out) is det.
 
-atsort__can_choose([], _All, _MustPredmap, CanChoose, CanChoose).
-atsort__can_choose([Node | Nodes], All, MustPredmap, CanChoose0, CanChoose) :-
+atsort__can_choose([], _All, _MustPredmap, !CanChoose).
+atsort__can_choose([Node | Nodes], All, MustPredmap, !CanChoose) :-
 	( map__search(MustPredmap, Node, MustPrednodes) ->
 		( atsort__must_avoid(All, MustPrednodes) ->
-			CanChoose1 = [Node | CanChoose0]
+			!:CanChoose = [Node | !.CanChoose]
 		;
-			CanChoose1 = CanChoose0
+			true
 		)
 	;
-		CanChoose1 = [Node | CanChoose0]
+		!:CanChoose = [Node | !.CanChoose]
 	),
-	atsort__can_choose(Nodes, All, MustPredmap, CanChoose1, CanChoose).
+	atsort__can_choose(Nodes, All, MustPredmap, !CanChoose).
 
 	% None of the members of the first list occur in the second.
 
@@ -171,39 +173,42 @@
 	list(list(T))::in, list(list(T))::out, list(T)::out,
 	list(list(T))::in, list(list(T))::out) is det.
 
-atsort__repeat_source_sink(Nodes0, Succmap0, Succmap, Predmap0, Predmap,
-		Source0, Source, Mid, Sink0, Sink) :-
-	atsort__source_sink(Nodes0, Succmap0, Predmap0,
+atsort__repeat_source_sink(Nodes0, !Succmap, !Predmap, Source0, Source, Mid,
+		Sink0, Sink) :-
+	atsort__source_sink(Nodes0, !.Succmap, !.Predmap,
 		[], Source1, [], Mid1, [], Sink1),
 	( Source1 = [], Sink1 = [] ->
-		Succmap = Succmap0,
-		Predmap = Predmap0,
 		Source = Source0,
 		Sink = Sink0,
 		Mid = Mid1
 	;
 		list__delete_elems(Nodes0, Source1, Nodes1),
 		list__delete_elems(Nodes1, Sink1, Nodes2),
+		Succmap0 = !.Succmap,
+		Predmap0 = !.Predmap,
 		atsort__map_delete_all_source_links(Source1,
-			Succmap0, Predmap0, Predmap1),
+			Succmap0, !Predmap),
 		atsort__map_delete_all_sink_links(Sink1,
-			Predmap0, Succmap0, Succmap1),
-		atsort__map_delete_all_nodes(Source1, Succmap1, Succmap1_5),
-		atsort__map_delete_all_nodes(Source1, Predmap1, Predmap1_5),
-		atsort__map_delete_all_nodes(Sink1, Succmap1_5, Succmap2),
-		atsort__map_delete_all_nodes(Sink1, Predmap1_5, Predmap2),
-		( Source1 = [] ->
+			Predmap0, !Succmap),
+		atsort__map_delete_all_nodes(Source1, !Succmap),
+		atsort__map_delete_all_nodes(Source1, !Predmap),
+		atsort__map_delete_all_nodes(Sink1, !Succmap),
+		atsort__map_delete_all_nodes(Sink1, !Predmap),
+		(
+			Source1 = [],
 			Source2 = Source0
 		;
+			Source1 = [_ | _],
 			Source2 = [Source1 | Source0]
 		),
-		( Sink1 = [] ->
+		(
+			Sink1 = [],
 			Sink2 = Sink0
 		;
+			Sink1 = [_ | _],
 			Sink2 = [Sink1 | Sink0]
 		),
-		atsort__repeat_source_sink(Nodes2,
-			Succmap2, Succmap, Predmap2, Predmap,
+		atsort__repeat_source_sink(Nodes2, !Succmap, !Predmap,
 			Source2, Source, Mid, Sink2, Sink)
 	).
 
Index: compiler/base_typeclass_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/base_typeclass_info.m,v
retrieving revision 1.32
diff -u -b -r1.32 base_typeclass_info.m
--- compiler/base_typeclass_info.m	21 Jan 2005 03:27:34 -0000	1.32
+++ compiler/base_typeclass_info.m	19 Mar 2005 01:47:51 -0000
@@ -27,8 +27,8 @@
 
 :- import_module list.
 
-:- pred base_typeclass_info__generate_rtti(module_info, list(rtti_data)).
-:- mode base_typeclass_info__generate_rtti(in, out) is det.
+:- pred base_typeclass_info__generate_rtti(module_info::in,
+	list(rtti_data)::out) is det.
 
 :- implementation.
 
@@ -46,7 +46,14 @@
 :- import_module parse_tree__prog_out.
 :- import_module parse_tree__prog_type.
 
-:- import_module bool, int, string, map, std_util, require, term, assoc_list.
+:- import_module assoc_list.
+:- import_module bool.
+:- import_module int.
+:- import_module map.
+:- import_module require.
+:- import_module std_util.
+:- import_module string.
+:- import_module term.
 
 %---------------------------------------------------------------------------%
 
@@ -106,10 +113,9 @@
 
 %----------------------------------------------------------------------------%
 
-:- pred base_typeclass_info__gen_body(maybe(list(hlds_class_proc)),
-	list(type), list(class_constraint), module_info, class_id,
-	base_typeclass_info).
-:- mode base_typeclass_info__gen_body(in, in, in, in, in, out) is det.
+:- pred base_typeclass_info__gen_body(maybe(list(hlds_class_proc))::in,
+	list(type)::in, list(class_constraint)::in, module_info::in,
+	class_id::in, base_typeclass_info::out) is det.
 
 base_typeclass_info__gen_body(no, _, _, _, _, _) :-
 	error("pred_proc_ids should have been filled in by check_typeclass.m").
@@ -134,9 +140,8 @@
 	BaseTypeClassInfo = base_typeclass_info(NumExtra, NumConstraints,
 		SuperClassCount, ClassArity, NumMethods, ProcLabels).
 
-:- pred base_typeclass_info__construct_proc_labels(list(pred_proc_id),
-	module_info, list(rtti_proc_label)).
-:- mode base_typeclass_info__construct_proc_labels(in, in, out) is det.
+:- pred base_typeclass_info__construct_proc_labels(list(pred_proc_id)::in,
+	module_info::in, list(rtti_proc_label)::out) is det.
 
 base_typeclass_info__construct_proc_labels([], _, []).
 base_typeclass_info__construct_proc_labels([proc(PredId, ProcId) | Procs],
@@ -147,9 +152,8 @@
 
 %----------------------------------------------------------------------------%
 
-:- pred base_typeclass_info__gen_superclass_count(class_id, module_info,
-	int, int).
-:- mode base_typeclass_info__gen_superclass_count(in, in, out, out) is det.
+:- pred base_typeclass_info__gen_superclass_count(class_id::in, module_info::in,
+	int::out, int::out) is det.
 
 base_typeclass_info__gen_superclass_count(ClassId, ModuleInfo,
 		NumSuperClasses, ClassArity) :-
Index: compiler/basic_block.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/basic_block.m,v
retrieving revision 1.18
diff -u -b -r1.18 basic_block.m
--- compiler/basic_block.m	19 Jan 2005 03:10:28 -0000	1.18
+++ compiler/basic_block.m	19 Mar 2005 01:48:13 -0000
@@ -20,7 +20,10 @@
 :- import_module ll_backend__llds.
 :- import_module mdbcomp__prim_data.
 
-:- import_module list, map, std_util, counter.
+:- import_module counter.
+:- import_module list.
+:- import_module map.
+:- import_module std_util.
 
 :- type block_map	==	map(label, block_info).
 
@@ -53,7 +56,10 @@
 :- implementation.
 
 :- import_module ll_backend__opt_util.
-:- import_module bool, int, require.
+
+:- import_module bool.
+:- import_module int.
+:- import_module require.
 
 create_basic_blocks(Instrs0, Comments, ProcLabel, !C, LabelSeq, BlockMap) :-
 	opt_util__get_prologue(Instrs0, LabelInstr, Comments,
Index: compiler/build_mode_constraints.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/build_mode_constraints.m,v
retrieving revision 1.2
diff -u -b -r1.2 build_mode_constraints.m
--- compiler/build_mode_constraints.m	25 Feb 2005 12:13:04 -0000	1.2
+++ compiler/build_mode_constraints.m	19 Mar 2005 02:06:23 -0000
@@ -234,8 +234,8 @@
 		svbimap.det_insert(RepVar, NewMCvar, !VarMap)
 	).
 
-add_mc_vars_for_goal(
-	PredId, ProgVarset, GoalExpr - GoalInfo, !Varset, !VarMap) :-
+add_mc_vars_for_goal(PredId, ProgVarset, GoalExpr - GoalInfo,
+        !Varset, !VarMap) :-
 	goal_info_get_nonlocals(GoalInfo, Nonlocals),
 	goal_info_get_goal_path(GoalInfo, GoalPath),
 
@@ -258,36 +258,45 @@
 		{!.Varset, !.VarMap}
 	),
 		% Switch on GoalExpr for recursion
-	(	GoalExpr = conj(Goals),
+	(
+        GoalExpr = conj(Goals),
 		list.foldl2(
 			add_mc_vars_for_goal(PredId, ProgVarset),
 			Goals,
 			!Varset,
 			!VarMap
 		)
-	;	GoalExpr = call(_, _, _, _, _, _)
-	;	GoalExpr = generic_call(_, _, _, _)
-	;	GoalExpr = switch(_, _, Cases),
+	;
+        GoalExpr = call(_, _, _, _, _, _)
+	;
+        GoalExpr = generic_call(_, _, _, _)
+	;
+        GoalExpr = switch(_, _, Cases),
 		Goals = list.map(func(case(_, Goal)) = Goal, Cases),
 		list.foldl2(add_mc_vars_for_goal(PredId, ProgVarset), Goals,
 			!Varset, !VarMap)
-	;	GoalExpr = unify(_, _, _, _, _)
-	;	GoalExpr = disj(Goals),
+	;
+        GoalExpr = unify(_, _, _, _, _)
+	;
+        GoalExpr = disj(Goals),
 		list.foldl2(
 			add_mc_vars_for_goal(PredId, ProgVarset),
 			Goals,
 			!Varset,
 			!VarMap
 		)
-	;	GoalExpr = not(Goal),
+	;
+        GoalExpr = not(Goal),
 		add_mc_vars_for_goal(
 			PredId, ProgVarset, Goal, !Varset, !VarMap
 		)
-	;	GoalExpr = some(_, _, Goal),
+	;
+        GoalExpr = some(_, _, Goal),
 		add_mc_vars_for_goal(
 			PredId, ProgVarset, Goal, !Varset, !VarMap
 		)
-	;	GoalExpr = if_then_else(_, Cond, Then, Else),
+	;
+        GoalExpr = if_then_else(_, Cond, Then, Else),
 		Goals = [Cond, Then, Else],
 		list.foldl2(
 			add_mc_vars_for_goal(PredId, ProgVarset),
@@ -295,9 +304,12 @@
 			!Varset,
 			!VarMap
 		)
-	;	GoalExpr = foreign_proc(_, _, _, _, _, _)
-	;	GoalExpr = par_conj(_Goals)
-	;	GoalExpr = shorthand(_ShorthandGoalExpr)
+	;
+        GoalExpr = foreign_proc(_, _, _, _, _, _)
+	;
+        GoalExpr = par_conj(_Goals)
+	;
+        GoalExpr = shorthand(_ShorthandGoalExpr)
 	).
 
 rep_var_to_string(ProgVarset, (ProgVar `in` _) `at` GoalPath) = RepString :-
@@ -399,40 +411,31 @@
 		ArgModeDecls
 	),
 
-	(	ArgModeDecls = [],
+	(
 			% No modes declared, must be in the same SCC as
 			% the calling predicate.
+        ArgModeDecls = [],
 
 			% Get the head variables of the called pred.
 		pred_info_clauses_info(PredInfo, ClausesInfo),
 		clauses_info_headvars(ClausesInfo, HeadVars),
 
-		call_headvar_constraints(
-			VarMap, GoalPath,
-			PredId, Args, CalledPred, HeadVars,
-			Constraints
-		)
-	;	ArgModeDecls = [_| _],
+		call_headvar_constraints( VarMap, GoalPath, PredId, Args, CalledPred,
+            HeadVars, Constraints)
+	;
 			% At least one declared mode
+        ArgModeDecls = [_| _],
 
-/*
-		list.map(
-			add_sufficient_in_modes_for_type_info_args(Args),
-			ArgModeDecls,
-			FullArgModeDecls
-		),	% XXX type_info args should be at the start and
-			% should be 'in' so that is what this predicate
-			% adds however, I am not happy with it.
-*/
-		call_mode_decls_constraints(
-			ModuleInfo,
-			VarMap,
-			PredId,
-			ArgModeDecls,
-			GoalPath,
-			Args,
-			Constraints
-		)
+%		list.map(
+%			add_sufficient_in_modes_for_type_info_args(Args),
+%			ArgModeDecls,
+%			FullArgModeDecls
+%		),	% XXX type_info args should be at the start and
+%			% should be 'in' so that is what this predicate
+%			% adds however, I am not happy with it.
+
+		call_mode_decls_constraints(ModuleInfo, VarMap, PredId, ArgModeDecls,
+			GoalPath, Args, Constraints)
 	).
 
 	% XXX Need to do something here.
@@ -457,12 +460,8 @@
 			% Goal: LHSvar = RHSvar
 		Constraints = [
 			atomic_constraint(at_most_one([
-				prog_var_at_path(
-					VarMap, PredId, GoalPath, LHSvar
-				),
-				prog_var_at_path(
-					VarMap, PredId, GoalPath, RHSvar
-				)
+				prog_var_at_path(VarMap, PredId, GoalPath, LHSvar),
+				prog_var_at_path(VarMap, PredId, GoalPath, RHSvar)
 			]))	% At most one of the left and right hand
 				% sides of a unification is produced
 				% at the unification.
@@ -473,33 +472,24 @@
 			VarMap, PredId, GoalPath, LHSvar
 		),
 		ArgsProducedHere =
-			list.map(
-				prog_var_at_path(VarMap, PredId, GoalPath),
-				Args
-			),
+			list.map(prog_var_at_path(VarMap, PredId, GoalPath), Args),
 		(	
             ArgsProducedHere = [OneArgProducedHere, _Two| _],
 				% Goal: LHSvar = functor(Args)
 			Constraints = [
+                    % If one arg is produced here, then they all are.
+				atomic_constraint(equivalent(ArgsProducedHere)),
+                    % At most one side of the unification is produced.
 				atomic_constraint(
-					equivalent(ArgsProducedHere)
-				),		% If one arg is produced here,
-						% then they all are.
-				atomic_constraint(at_most_one([
-					LHSproducedHere,
-					OneArgProducedHere
-				]))		% At most one side of the
-						% unification is produced.
+                    at_most_one([LHSproducedHere, OneArgProducedHere]))
 			]
 		;	
             ArgsProducedHere = [OneArgProducedHere],
 				% Goal: LHSvar = functor(Arg)
 			Constraints = [
-				atomic_constraint(at_most_one([
-					LHSproducedHere,
-					OneArgProducedHere
-				]))		% At most one side of the
-						% unification is produced.
+                    % At most one side of the unification is produced.
+				atomic_constraint(
+                    at_most_one([LHSproducedHere, OneArgProducedHere]))
 			]
 		;	
             ArgsProducedHere = [],
@@ -531,23 +521,19 @@
 		DisjunctGoalPaths
 	),
 
-	list.map(
-		goal_constraints(ModuleInfo, VarMap, PredId),
-		Goals,
-		DisjunctConstraints
-	),
+	list.map(goal_constraints(ModuleInfo, VarMap, PredId),
+		Goals, DisjunctConstraints),
 
 	Constraints = list.condense([
 		list.map_corresponding(
-			func(X, Ys) = atomic_constraint(equivalent([X|Ys])),
+			func(X, Ys) = atomic_constraint(equivalent([X | Ys])),
 				% A variable bound at any disjunct is
 				% bound for the disjunct as a whole. If
 				% a variable can be bound at one
 				% conjunct it must be able to be bound
 				% at any.
-			NonlocalsHere,
-			NonlocalsAtDisjuncts
-		)|
+			NonlocalsHere, NonlocalsAtDisjuncts
+		) |
 		DisjunctConstraints
 	]).
 
@@ -561,9 +547,8 @@
 	NonlocalsConstraintVars = set.fold(
 		func(Nonlocal, MCVars) = [
 			prog_var_at_path(VarMap, PredId, GoalPath, Nonlocal),
-			prog_var_at_path(
-				VarMap, PredId, NegatedGoalPath, Nonlocal
-			)|
+			prog_var_at_path(VarMap, PredId, NegatedGoalPath, Nonlocal)
+            |
 			MCVars
 		],
 		Nonlocals,
@@ -705,25 +690,19 @@
 	module_info_pred_proc_info(ModuleInfo, CalledPred, ProcID, _, ProcInfo),
 	( proc_info_maybe_declared_argmodes(ProcInfo, yes(_OrigDecl)) ->
         proc_info_argmodes(ProcInfo, Decl),
-/*
-		add_sufficient_in_modes_for_type_info_args(
-			CallArgs,
-			Decl,
-			FullDecl
-		),	% XXX type_info args should be at the start and
-			% should be 'in' so that is what this predicate
-			% adds however, I am not happy with it.
-*/
-		call_mode_decls_constraints(
-			ModuleInfo,
-			VarMap,
-			PredId,
-			[Decl],
-			GoalPath,
-			CallArgs,
-			Constraints
-		)	% This pred should strip the disj(conj()) for the
+
+%		add_sufficient_in_modes_for_type_info_args(
+%			CallArgs,
+%			Decl,
+%			FullDecl
+%		),	% XXX type_info args should be at the start and
+%			% should be 'in' so that is what this predicate
+%			% adds however, I am not happy with it.
+
+            % This pred should strip the disj(conj()) for the
 			% single declaration.
+		call_mode_decls_constraints(ModuleInfo, VarMap, PredId, [Decl],
+			GoalPath, CallArgs, Constraints)
 	;	
 		unexpected(this_file, "no mode declaration for foreign proc")
 	).
@@ -872,12 +851,7 @@
 	[conj(list.map_corresponding(
 		(func(CVar, Mode) =
 			atomic_constraint(equiv_bool(CVar, IsProduced)) :-
-			mode_util.mode_get_insts(
-				ModuleInfo,
-				Mode,
-				InitialInst,
-				FinalInst
-			),
+			mode_util.mode_get_insts(ModuleInfo, Mode, InitialInst, FinalInst),
 			(	
 			    % Already produced.
                 not inst_match.inst_is_free(ModuleInfo, InitialInst)
@@ -904,10 +878,7 @@
 	( Diff = 0 ->
         FullDecl = Decl
 	; Diff > 0 ->
-        FullDecl = list.append(
-			list.duplicate(Diff, prog_mode.in_mode),
-			Decl
-		)
+        FullDecl = list.append(list.duplicate(Diff, prog_mode.in_mode), Decl)
 	;	
         unexpected(this_file, "Too many mode declared args.m")
 	).
@@ -956,8 +927,7 @@
 :- pred fold_goal_into_var_position_maps(
     mc_var_map::in, pred_id::in, nonlocals::in, hlds_goal::in,
    	multi_map(prog_var, mc_var)::in, multi_map(prog_var, mc_var)::out,
-   	multi_map(prog_var, mc_var)::in, multi_map(prog_var, mc_var)::out
-    ) is det.
+   	multi_map(prog_var, mc_var)::in, multi_map(prog_var, mc_var)::out) is det.
 
 fold_goal_into_var_position_maps(VarMap, PredId, Nonlocals,
 	    _SubGoalExpr - SubGoalInfo, !LocalsMap, !NonlocalsMap) :-
@@ -985,8 +955,7 @@
 	%
 :- pred fold_variable_into_var_position_map(
 	mc_var_map::in, pred_id::in, goal_path::in, prog_var::in,
-	multi_map(prog_var, mc_var)::in, multi_map(prog_var, mc_var)::out
-	) is det .
+	multi_map(prog_var, mc_var)::in, multi_map(prog_var, mc_var)::out) is det.
 
 fold_variable_into_var_position_map(VarMap, PredId, GoalPath, ProgVar, !Map) :-
 	MCVar = prog_var_at_path(VarMap, PredId, GoalPath, ProgVar),
@@ -1004,10 +973,9 @@
 
 fold_nonlocal_var_into_conj_constraints(VarMap, PredId, NonlocalsMap,
         GoalPath, ProgVar, !Constraints) :-
-	list.append([
-		atomic_constraint(equiv_disj(ProgVarAtGoalPath, Xs)),
+    NewConstraints = [atomic_constraint(equiv_disj(ProgVarAtGoalPath, Xs)),
 		atomic_constraint(at_most_one(Xs))],
-		!Constraints),
+	list.append(NewConstraints, !Constraints),
 	ProgVarAtGoalPath = prog_var_at_path(VarMap, PredId, GoalPath, ProgVar),
 	Xs = multi_map.lookup(NonlocalsMap, ProgVar).
 
Index: compiler/bytecode.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/bytecode.m,v
retrieving revision 1.58
diff -u -b -r1.58 bytecode.m
--- compiler/bytecode.m	1 Feb 2005 07:11:27 -0000	1.58
+++ compiler/bytecode.m	19 Mar 2005 02:11:44 -0000
@@ -20,15 +20,18 @@
 :- import_module mdbcomp__prim_data.
 :- import_module parse_tree__prog_data.
 
-:- import_module char, list, std_util, io.
+:- import_module char.
+:- import_module io.
+:- import_module list.
+:- import_module std_util.
 
 :- type byte_tree	==	tree(list(byte_code)).
 
-:- type byte_code	--->	enter_pred(byte_pred_id, int,
-					byte_is_func, int)
+:- type byte_code
+	--->	enter_pred(byte_pred_id, int, byte_is_func, int)
 			;	endof_pred
-			;	enter_proc(byte_proc_id, determinism,
-					int, int, int, list(byte_var_info))
+	;	enter_proc(byte_proc_id, determinism, int, int, int,
+			list(byte_var_info))
 			;	endof_proc
 			;	label(byte_label_id)
 			;	enter_disjunction(byte_label_id)
@@ -39,8 +42,7 @@
 			;	endof_switch
 			;	enter_switch_arm(byte_cons_id, byte_label_id)
 			;	endof_switch_arm(byte_label_id)
-			;	enter_if(byte_label_id, byte_label_id,
-					byte_temp)
+	;	enter_if(byte_label_id, byte_label_id, byte_temp)
 			;	enter_then(byte_temp)
 			;	endof_then(byte_label_id)
 			;	enter_else(byte_temp)
@@ -52,22 +54,18 @@
 			;	endof_commit(byte_temp)
 			;	assign(byte_var, byte_var)
 			;	test(byte_var, byte_var, byte_test_id)
-			;	construct(byte_var, byte_cons_id,
-					list(byte_var))
-			;	deconstruct(byte_var, byte_cons_id,
-					list(byte_var))
+	;	construct(byte_var, byte_cons_id, list(byte_var))
+	;	deconstruct(byte_var, byte_cons_id, list(byte_var))
 			;	complex_construct(byte_var, byte_cons_id,
 					list(pair(byte_var, byte_dir)))
 			;	complex_deconstruct(byte_var, byte_cons_id,
 					list(pair(byte_var, byte_dir)))
 			;	place_arg(byte_reg_type, int, byte_var)
 			;	pickup_arg(byte_reg_type, int, byte_var)
-			;	call(byte_module_id, byte_pred_id,
-					arity, byte_is_func, byte_proc_id)
-			;	higher_order_call(byte_var, arity, arity,
-					determinism)
-			;	builtin_binop(binary_op, byte_arg, byte_arg,
-					byte_var)
+	;	call(byte_module_id, byte_pred_id, arity, byte_is_func,
+			byte_proc_id)
+	;	higher_order_call(byte_var, arity, arity, determinism)
+	;	builtin_binop(binary_op, byte_arg, byte_arg, byte_var)
 			;	builtin_unop(unary_op, byte_arg, byte_var)
 			;	builtin_bintest(binary_op, byte_arg, byte_arg)
 			;	builtin_untest(unary_op, byte_arg)
@@ -75,50 +73,49 @@
 			;	semidet_success_check
 			;	fail
 			;	context(int)
-			;	not_supported
-			.
+	;	not_supported.
 
 	% Currently we only support integer registers.
 	% This might one day be extended to support separate
 	% floating-point registers.
-:- type byte_reg_type	--->	r.	% general-purpose (integer) register.
+:- type byte_reg_type
+	--->	r.	% general-purpose (integer) register.
 
-:- type byte_cons_id	--->	cons(byte_module_id, string,
-					arity, byte_cons_tag)
+:- type byte_cons_id
+	--->	cons(byte_module_id, string, arity, byte_cons_tag)
 			;	int_const(int)
 			;	string_const(string)
 			;	float_const(float)
-			;	pred_const(byte_module_id, byte_pred_id,
-					arity, byte_is_func, byte_proc_id)
-			;	type_ctor_info_const(byte_module_id, string,
-					int)
-			;	base_typeclass_info_const(byte_module_id,
-					class_id, string)
+	;	pred_const(byte_module_id, byte_pred_id, arity, byte_is_func,
+			byte_proc_id)
+	;	type_ctor_info_const(byte_module_id, string, int)
+	;	base_typeclass_info_const(byte_module_id, class_id, string)
 			;	type_info_cell_constructor
 			;	typeclass_info_cell_constructor
-			;	char_const(char)
-			.
+	;	char_const(char).
 
-:- type byte_var_info	--->	var_info(string, type).
+:- type byte_var_info
+	--->	var_info(string, type).
 
-:- type byte_cons_tag	--->	no_tag
+:- type byte_cons_tag
+	--->	no_tag
 			;	unshared_tag(tag_bits)
 			;	shared_remote_tag(tag_bits, int)
 			;	shared_local_tag(tag_bits, int)
-			;	enum_tag(int)
-			.
+	;	enum_tag(int).
 
-:- type byte_arg	--->	var(byte_var)
+:- type byte_arg
+	--->	var(byte_var)
 			;	int_const(int)
-			;	float_const(float)
-			.
+	;	float_const(float).
 
-:- type byte_dir	--->	to_arg
+:- type byte_dir
+	--->	to_arg
 			;	to_var
-			;	to_none
-			.
+	;	to_none.
 
-:- type byte_test_id	--->	int_test
+:- type byte_test_id
+	--->	int_test
 			;	char_test
 			;	string_test
 			;	float_test
@@ -147,7 +144,11 @@
 :- import_module hlds__hlds_pred.
 :- import_module parse_tree__prog_out.
 
-:- import_module library, assoc_list, int, string, require.
+:- import_module assoc_list.
+:- import_module int.
+:- import_module library.
+:- import_module require.
+:- import_module string.
 
 :- pred bytecode__version(int::out) is det.
 
@@ -224,7 +225,8 @@
 	output_is_func(IsFunc),
 	output_length(ProcCount).
 output_args(endof_pred) --> [].
-output_args(enter_proc(ProcId, Detism, LabelCount, LabelId, TempCount, Vars)) -->
+output_args(enter_proc(ProcId, Detism, LabelCount, LabelId, TempCount, Vars))
+		-->
 	output_proc_id(ProcId),
 	output_determinism(Detism),
 	output_length(LabelCount),
@@ -677,7 +679,6 @@
 debug_test_id(string_test)	--> debug_string("string").
 debug_test_id(float_test) 	--> debug_string("float").
 debug_test_id(enum_test) 	--> debug_string("enum").
-
 
 %---------------------------------------------------------------------------%
 
Index: compiler/bytecode_data.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/bytecode_data.m,v
retrieving revision 1.15
diff -u -b -r1.15 bytecode_data.m
--- compiler/bytecode_data.m	21 Jul 2004 16:04:45 -0000	1.15
+++ compiler/bytecode_data.m	22 Mar 2005 11:12:32 -0000
@@ -18,7 +18,10 @@
 
 :- interface.
 
-:- import_module io, int, list, string.
+:- import_module int.
+:- import_module io.
+:- import_module list.
+:- import_module string.
 
 	% XXX this assumes strings contain 8-bit characters
 :- pred output_string(string::in, io::di, io::uo) is det.
@@ -26,40 +29,32 @@
 
 :- pred output_byte(int::in, io::di, io::uo) is det.
 
-/*
-** Spit out an `int' in a portable `highest common denominator' format.
-** This format is: big-endian, 64-bit, 2's-complement int.
-**
-** NOTE: We -assume- the machine architecture uses 2's-complement.
-*/
-
+	% Spit out an `int' in a portable `highest common denominator' format.
+	% This format is: big-endian, 64-bit, 2's-complement int.
+	%
+	% NOTE: We -assume- the machine architecture uses 2's-complement.
+	%
 :- pred output_int(int::in, io::di, io::uo) is det.
 :- pred int_to_byte_list(int::in, list(int)::out) is det.
 
-/*
-** Same as output_int and int_to_byte_list, except only use 32 bits.
-*/
-
+	% Same as output_int and int_to_byte_list, except only use 32 bits.
+	%
 :- pred output_int32(int::in, io::di, io::uo) is det.
 :- pred int32_to_byte_list(int::in, list(int)::out) is det.
 
-/*
-** Spit out a `short' in a portable format.
-** This format is: big-endian, 16-bit, 2's-complement.
-**
-** NOTE: We -assume- the machine architecture uses 2's-complement.
-*/
-
+	% Spit out a `short' in a portable format.
+	% This format is: big-endian, 16-bit, 2's-complement.
+	%
+	% NOTE: We -assume- the machine architecture uses 2's-complement.
+	%
 :- pred output_short(int::in, io::di, io::uo) is det.
 :- pred short_to_byte_list(int::in, list(int)::out) is det.
 
-/*
-** Spit out a `float' in a portable `highest common denominator format.
-** This format is: big-endian, 64-bit, IEEE-754 floating point value.
-**
-** NOTE: We -assume- the machine architecture uses IEEE-754.
-*/
-
+	% Spit out a `float' in a portable `highest common denominator format.
+	% This format is: big-endian, 64-bit, IEEE-754 floating point value.
+	%
+	% NOTE: We -assume- the machine architecture uses IEEE-754.
+	%
 :- pred output_float(float::in, io::di, io::uo) is det.
 :- pred float_to_byte_list(float::in, list(int)::out) is det.
 
@@ -69,7 +64,8 @@
 
 :- import_module parse_tree__error_util.
 
-:- import_module char, require.
+:- import_module char.
+:- import_module require.
 
 output_string(Val, !IO) :-
 	% XXX this assumes strings contain 8-bit characters
Index: compiler/bytecode_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/bytecode_gen.m,v
retrieving revision 1.87
diff -u -b -r1.87 bytecode_gen.m
--- compiler/bytecode_gen.m	21 Jan 2005 06:20:35 -0000	1.87
+++ compiler/bytecode_gen.m	22 Mar 2005 11:12:38 -0000
@@ -18,7 +18,8 @@
 :- import_module bytecode_backend__bytecode.
 :- import_module hlds__hlds_module.
 
-:- import_module io, list.
+:- import_module io.
+:- import_module list.
 
 :- pred bytecode_gen__module(module_info::in, list(byte_code)::out,
 	io::di, io::uo) is det.
@@ -57,8 +58,19 @@
 :- import_module parse_tree__prog_data.
 :- import_module parse_tree__prog_out.
 :- import_module parse_tree__prog_type.
-:- import_module bool, int, string, list, assoc_list, set, map, varset.
-:- import_module std_util, require, term, counter.
+
+:- import_module assoc_list.
+:- import_module bool.
+:- import_module counter.
+:- import_module int.
+:- import_module list.
+:- import_module map.
+:- import_module require.
+:- import_module set.
+:- import_module std_util.
+:- import_module string.
+:- import_module term.
+:- import_module varset.
 
 %---------------------------------------------------------------------------%
 
@@ -76,9 +88,11 @@
 	module_info_preds(ModuleInfo, PredTable),
 	map__lookup(PredTable, PredId, PredInfo),
 	ProcIds = pred_info_non_imported_procids(PredInfo),
-	( ProcIds = [] ->
+	(
+		ProcIds = [],
 		PredCode = empty
 	;
+		ProcIds = [_ | _],
 		bytecode_gen__pred(PredId, ProcIds, PredInfo, ModuleInfo,
 			ProcsCode, !IO),
 		predicate_name(ModuleInfo, PredId, PredName),
Index: compiler/c_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/c_util.m,v
retrieving revision 1.23
diff -u -b -r1.23 c_util.m
--- compiler/c_util.m	21 Mar 2005 04:45:44 -0000	1.23
+++ compiler/c_util.m	22 Mar 2005 07:03:45 -0000
@@ -22,7 +22,12 @@
 :- import_module aditi_backend__rl_file.
 :- import_module backend_libs__builtin_ops.
 :- import_module mdbcomp__prim_data.
-:- import_module io, char, string, int, std_util.
+
+:- import_module char.
+:- import_module int.
+:- import_module io.
+:- import_module std_util.
+:- import_module string.
 
 %-----------------------------------------------------------------------------%
 %
@@ -148,12 +153,13 @@
 
 :- implementation.
 
+:- import_module backend_libs__name_mangle.
 :- import_module libs__globals.
 :- import_module libs__options.
-:- import_module backend_libs__name_mangle.
 :- import_module parse_tree__prog_foreign.
 
-:- import_module list, bool.
+:- import_module bool.
+:- import_module list.
 
 %-----------------------------------------------------------------------------%
 %
@@ -389,52 +395,53 @@
 
 %-----------------------------------------------------------------------------%
 
-c_util__output_rl_file(ModuleName, MaybeRLFile) -->
-	globals__io_lookup_bool_option(aditi, Aditi),
-	( { Aditi = no } ->
-		[]
+c_util__output_rl_file(ModuleName, MaybeRLFile, !IO) :-
+	globals__io_lookup_bool_option(aditi, Aditi, !IO),
+	(
+		Aditi = no
 	;
-		io__write_string("\n\n/* Aditi-RL code for this module. */\n"),
-		{ RLDataConstName = make_rl_data_name(ModuleName) },
-		io__write_string("const char "),
-		io__write_string(RLDataConstName),
-		io__write_string("[] = {"),
+		Aditi = yes,
+		io__write_string("\n\n/* Aditi-RL code for this module. */\n",
+			!IO),
+		RLDataConstName = make_rl_data_name(ModuleName),
+		io__write_string("const char ", !IO),
+		io__write_string(RLDataConstName, !IO),
+		io__write_string("[] = {", !IO),
 		(
-			{ MaybeRLFile = yes(RLFile) },
+			MaybeRLFile = yes(RLFile),
 			rl_file__write_binary(c_util__output_rl_byte,
-				RLFile, Length),
-			io__write_string("0};\n")
+				RLFile, Length, !IO),
+			io__write_string("0};\n", !IO)
 		;
-			{ MaybeRLFile = no },
-			io__write_string("};\n"),
-			{ Length = 0 }
+			MaybeRLFile = no,
+			io__write_string("};\n", !IO),
+			Length = 0
 		),
 
 		% Store the length of the data in
 		% mercury__aditi_rl_data__<module>__length.
 
-		{ string__append(RLDataConstName, "__length",
-			RLDataConstLength) },
-		io__write_string("const int "),
-		io__write_string(RLDataConstLength),
-		io__write_string(" = "),
-		io__write_int(Length),
-		io__write_string(";\n\n")
+		string__append(RLDataConstName, "__length", RLDataConstLength),
+		io__write_string("const int ", !IO),
+		io__write_string(RLDataConstLength, !IO),
+		io__write_string(" = ", !IO),
+		io__write_int(Length, !IO),
+		io__write_string(";\n\n", !IO)
 	).
 
 :- pred c_util__output_rl_byte(int::in, io::di, io::uo) is det.
 
-c_util__output_rl_byte(Byte) -->
-	io__write_int(Byte),
-	io__write_string(", ").
+c_util__output_rl_byte(Byte, !IO) :-
+	io__write_int(Byte, !IO),
+	io__write_string(", ", !IO).
 
 %-----------------------------------------------------------------------------%
 
-output_c_file_intro_and_grade(SourceFileName, Version) -->
-	globals__io_lookup_int_option(num_tag_bits, NumTagBits),
-	{ string__int_to_string(NumTagBits, NumTagBitsStr) },
-	globals__io_lookup_bool_option(unboxed_float, UnboxedFloat),
-	{ UnboxedFloatStr = convert_bool_to_string(UnboxedFloat) },
+output_c_file_intro_and_grade(SourceFileName, Version, !IO) :-
+	globals__io_lookup_int_option(num_tag_bits, NumTagBits, !IO),
+	string__int_to_string(NumTagBits, NumTagBitsStr),
+	globals__io_lookup_bool_option(unboxed_float, UnboxedFloat, !IO),
+	UnboxedFloatStr = convert_bool_to_string(UnboxedFloat),
 
 	io__write_strings([
 		"/*\n",
@@ -452,7 +459,7 @@
 		"** END_OF_C_GRADE_INFO\n",
 		"*/\n",
 		"\n"
-	]).
+	], !IO).
 
 :- func convert_bool_to_string(bool) = string.
 
Index: compiler/call_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/call_gen.m,v
retrieving revision 1.161
diff -u -b -r1.161 call_gen.m
--- compiler/call_gen.m	2 Sep 2004 04:31:34 -0000	1.161
+++ compiler/call_gen.m	19 Mar 2005 03:53:54 -0000
@@ -25,7 +25,8 @@
 :- import_module ll_backend__llds.
 :- import_module parse_tree__prog_data.
 
-:- import_module list, assoc_list.
+:- import_module assoc_list.
+:- import_module list.
 
 :- pred call_gen__generate_call(code_model::in, pred_id::in, proc_id::in,
 	list(prog_var)::in, hlds_goal_info::in, code_tree::out,
@@ -72,7 +73,14 @@
 :- import_module ll_backend__code_util.
 :- import_module ll_backend__trace.
 
-:- import_module bool, int, string, map, set, std_util, require, varset.
+:- import_module bool.
+:- import_module int.
+:- import_module map.
+:- import_module require.
+:- import_module set.
+:- import_module std_util.
+:- import_module string.
+:- import_module varset.
 
 %---------------------------------------------------------------------------%
 
@@ -126,11 +134,7 @@
 		% handle the failure.
 	call_gen__handle_failure(CodeModel, GoalInfo, FailHandlingCode, !CI),
 
-	Code =
-		tree(SetupCode,
-		tree(TraceCode,
-		tree(CallCode,
-		     FailHandlingCode))).
+	Code = tree_list([SetupCode, TraceCode, CallCode, FailHandlingCode]).
 
 %---------------------------------------------------------------------------%
 
@@ -238,12 +242,8 @@
 		% handle the failure.
 	call_gen__handle_failure(CodeModel, GoalInfo, FailHandlingCode, !CI),
 
-	Code =
-		tree(SetupCode,
-		tree(NonVarCode,
-		tree(TraceCode,
-		tree(CallCode,
-		     FailHandlingCode)))).
+	Code = tree_list([SetupCode, NonVarCode, TraceCode, CallCode,
+		FailHandlingCode]).
 
 %---------------------------------------------------------------------------%
 
@@ -354,10 +354,8 @@
 				label(ContLab)
 					- ""
 			]),
-			FailHandlingCode =
-				tree(FailTestCode,
-				tree(FailCode,
-				     ContLabelCode))
+			FailHandlingCode = tree_list([FailTestCode,
+				FailCode, ContLabelCode])
 		)
 	;
 		FailHandlingCode = empty
Index: compiler/check_typeclass.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/check_typeclass.m,v
retrieving revision 1.63
diff -u -b -r1.63 check_typeclass.m
--- compiler/check_typeclass.m	1 Feb 2005 07:11:27 -0000	1.63
+++ compiler/check_typeclass.m	22 Mar 2005 11:14:37 -0000
@@ -53,7 +53,8 @@
 :- import_module hlds__hlds_module.
 :- import_module hlds__make_hlds.
 
-:- import_module bool, io.
+:- import_module bool.
+:- import_module io.
 
 :- pred check_typeclass__check_typeclasses(qual_info::in, qual_info::out,
 	module_info::in, module_info::out, bool::out, io::di, io::uo) is det.
@@ -78,9 +79,17 @@
 :- import_module parse_tree__prog_out.
 :- import_module parse_tree__prog_util.
 
-:- import_module int, string.
-:- import_module list, assoc_list, map, set, svset, term, varset.
-:- import_module std_util, require.
+:- import_module assoc_list.
+:- import_module int.
+:- import_module list.
+:- import_module map.
+:- import_module require.
+:- import_module set.
+:- import_module std_util.
+:- import_module string.
+:- import_module svset.
+:- import_module term.
+:- import_module varset.
 
 check_typeclass__check_typeclasses(!QualInfo, !ModuleInfo, FoundError, !IO) :-
 	check_typeclass__check_instance_decls(!QualInfo, !ModuleInfo,
@@ -106,12 +115,12 @@
 		InstanceList, check_tc_info([], !.ModuleInfo, !.QualInfo),
 		check_tc_info(Errors, !:ModuleInfo, !:QualInfo), !IO),
 	(
-		Errors = []
-	->
+		Errors = [],
 		map__from_assoc_list(InstanceList, InstanceTable),
 		module_info_set_instances(InstanceTable, !ModuleInfo),
 		FoundError = no
 	;
+		Errors = [_ | _],
 		list__reverse(Errors, ErrorList),
 		WriteError = (pred(E::in, IO0::di, IO::uo) is det :-
 			E = ErrorContext - ErrorPieces,
@@ -924,9 +933,7 @@
 	list(class_path)::in, list(class_path)::out) is det.
 
 find_cycles(ClassTable, Path, ClassId, !Visited, !Cycles) :-
-	(
-		set.member(ClassId, !.Visited)
-	->
+	( set.member(ClassId, !.Visited) ->
 		(
 			find_cycle(ClassId, Path, [ClassId], Cycle)
 		->
@@ -953,9 +960,7 @@
 
 find_cycle(ClassId, [Head | Tail], Path0, Cycle) :-
 	Path = [Head | Path0],
-	(
-		ClassId = Head
-	->
+	( ClassId = Head ->
 		Cycle = Path
 	;
 		find_cycle(ClassId, Tail, Path, Cycle)
Index: compiler/clause_to_proc.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/clause_to_proc.m,v
retrieving revision 1.45
diff -u -b -r1.45 clause_to_proc.m
--- compiler/clause_to_proc.m	21 Jan 2005 06:20:36 -0000	1.45
+++ compiler/clause_to_proc.m	19 Mar 2005 02:23:12 -0000
@@ -11,7 +11,8 @@
 :- import_module hlds__hlds_module.
 :- import_module hlds__hlds_pred.
 
-:- import_module list, std_util.
+:- import_module list.
+:- import_module std_util.
 
 	% In the hlds, we initially record the clauses for a predicate
 	% in the clauses_info data structure which is part of the
@@ -58,7 +59,13 @@
 :- import_module parse_tree__prog_data.
 :- import_module parse_tree__prog_mode.
 
-:- import_module assoc_list, bool, int, set, map, varset, require.
+:- import_module assoc_list.
+:- import_module bool.
+:- import_module int.
+:- import_module map.
+:- import_module require.
+:- import_module set.
+:- import_module varset.
 
 maybe_add_default_func_modes([], Preds, Preds).
 maybe_add_default_func_modes([PredId | PredIds], Preds0, Preds) :-
Index: compiler/code_aux.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/code_aux.m,v
retrieving revision 1.68
diff -u -b -r1.68 code_aux.m
--- compiler/code_aux.m	10 Apr 2004 10:33:00 -0000	1.68
+++ compiler/code_aux.m	19 Mar 2005 02:23:41 -0000
@@ -44,7 +44,12 @@
 :- import_module ll_backend__llds.
 :- import_module ll_backend__llds_out.
 
-:- import_module string, list, assoc_list, map, std_util, varset.
+:- import_module assoc_list.
+:- import_module list.
+:- import_module map.
+:- import_module std_util.
+:- import_module string.
+:- import_module varset.
 
 %-----------------------------------------------------------------------------%
 
@@ -57,16 +62,16 @@
 
 code_aux__contains_simple_recursive_call_expr([Goal|Goals], CodeInfo, Last) :-
 	Goal = GoalExpr - _,
-	(
-		contains_only_builtins_expr(GoalExpr)
-	->
+	( contains_only_builtins_expr(GoalExpr) ->
 		code_aux__contains_simple_recursive_call_expr(Goals, CodeInfo,
 			Last)
 	;
 		code_aux__is_recursive_call(GoalExpr, CodeInfo),
-		( Goals = [] ->
+		(
+			Goals = [],
 			Last = yes
 		;
+			Goals = [_ | _],
 			contains_only_builtins_list(Goals),
 			Last = no
 		)
Index: compiler/code_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/code_gen.m,v
retrieving revision 1.135
diff -u -b -r1.135 code_gen.m
--- compiler/code_gen.m	1 Feb 2005 07:11:28 -0000	1.135
+++ compiler/code_gen.m	19 Mar 2005 03:53:58 -0000
@@ -38,7 +38,8 @@
 :- import_module ll_backend__global_data.
 :- import_module ll_backend__llds.
 
-:- import_module list, io.
+:- import_module io.
+:- import_module list.
 
 	% Translate a HLDS module to LLDS.
 
@@ -110,9 +111,19 @@
 :- import_module mdbcomp__prim_data.
 
 % Standard library modules
-:- import_module bool, char, int, string.
-:- import_module map, assoc_list, set, term, libs__tree, std_util, require.
-:- import_module counter, varset.
+:- import_module assoc_list.
+:- import_module bool.
+:- import_module char.
+:- import_module counter.
+:- import_module int.
+:- import_module libs__tree.
+:- import_module map.
+:- import_module require.
+:- import_module set.
+:- import_module std_util.
+:- import_module string.
+:- import_module term.
+:- import_module varset.
 
 %---------------------------------------------------------------------------%
 
@@ -165,15 +176,16 @@
 		module_info_globals(ModuleInfo, Globals),
 		globals__lookup_bool_option(Globals, very_verbose,
 			VeryVerbose),
-		( VeryVerbose = yes ->
+		(
+			VeryVerbose = yes,
 			io__write_string("% Generating code for ", !IO),
 			hlds_out__write_pred_id(ModuleInfo, PredId, !IO),
 			io__write_string("\n", !IO),
-			globals__lookup_bool_option(Globals,
-				statistics, Statistics),
+			globals__lookup_bool_option(Globals, statistics,
+				Statistics),
 			maybe_report_stats(Statistics, !IO)
 		;
-			true
+			VeryVerbose = no
 		),
 		generate_pred_code(ModuleInfo, !GlobalData,
 			PredId, PredInfo, ProcIds, Predicates)
@@ -249,11 +261,7 @@
 	module_info_globals(ModuleInfo, Globals),
 	continuation_info__basic_stack_layout_for_proc(PredInfo, Globals,
 		BasicStackLayout, ForceProcId),
-	( BasicStackLayout = yes ->
-		SaveSuccip = yes
-	;
-		SaveSuccip = no
-	),
+	SaveSuccip = BasicStackLayout,
 
 		% Initialise the code_info structure. Generate_category_code
 		% below will use the returned OutsideResumePoint as the
@@ -306,8 +314,7 @@
 	list__condense(FragmentList, Instructions0),
 	FrameInfo = frame(TotalSlots, MaybeSuccipSlot, _),
 	(
-		MaybeSuccipSlot = yes(SuccipSlot)
-	->
+		MaybeSuccipSlot = yes(SuccipSlot),
 			% The set of recorded live values at calls (for value
 			% numbering) and returns (for accurate gc and execution
 			% tracing) do not yet record the stack slot holding the
@@ -315,6 +322,7 @@
 		code_gen__add_saved_succip(Instructions0,
 			SuccipSlot, Instructions)
 	;
+		MaybeSuccipSlot = no,
 		Instructions = Instructions0
 	),
 
@@ -491,13 +499,16 @@
 maybe_add_tabling_pointer_var(ModuleInfo, PredId, ProcId, ProcInfo, ProcLabel,
 		!GlobalData) :-
 	proc_info_eval_method(ProcInfo, EvalMethod),
-	( eval_method_has_per_proc_tabling_pointer(EvalMethod) = yes ->
+	HasTablingPointer =
+		eval_method_has_per_proc_tabling_pointer(EvalMethod),
+	(
+		HasTablingPointer = yes,
 		module_info_name(ModuleInfo, ModuleName),
 		Var = tabling_pointer_var(ModuleName, ProcLabel),
 		global_data_add_new_proc_var(proc(PredId, ProcId), Var,
 			!GlobalData)
 	;
-		true
+		HasTablingPointer = no
 	).
 
 %---------------------------------------------------------------------------%
@@ -566,7 +577,8 @@
 		Goal = _ - GoalInfo,
 		goal_info_get_context(GoalInfo, BodyContext),
 		code_info__get_maybe_trace_info(!.CI, MaybeTraceInfo),
-		( MaybeTraceInfo = yes(TraceInfo) ->
+		(
+			MaybeTraceInfo = yes(TraceInfo),
 			trace__generate_external_event_code(call, TraceInfo,
 				BodyContext, MaybeCallExternalInfo, !CI),
 			(
@@ -580,6 +592,7 @@
 			),
 			MaybeTraceCallLabel = yes(TraceCallLabel)
 		;
+			MaybeTraceInfo = no,
 			TraceCallCode = empty,
 			MaybeTraceCallLabel = no
 		),
@@ -588,11 +601,8 @@
 			FrameInfo, EntryCode),
 		code_gen__generate_exit(model_det, FrameInfo, TraceSlotInfo,
 			BodyContext, _, ExitCode, !CI),
-		Code =
-			tree(EntryCode,
-			tree(TraceCallCode,
-			tree(BodyCode,
-			     ExitCode)))
+		Code = tree_list([EntryCode, TraceCallCode, BodyCode,
+			ExitCode])
 	).
 
 generate_category_code(model_semi, Goal, ResumePoint, TraceSlotInfo, Code,
@@ -640,15 +650,9 @@
 			MaybeFailExternalInfo = no,
 			TraceFailCode = empty
 		),
-		Code =
-			tree(EntryCode,
-			tree(TraceCallCode,
-			tree(BodyCode,
-			tree(ExitCode,
-			tree(ResumeCode,
-			tree(TraceFailCode,
-			tree(RestoreDeallocCode,
-			     FailCode)))))))
+		Code = tree_list([EntryCode, TraceCallCode, BodyCode,
+			ExitCode, ResumeCode, TraceFailCode,
+			RestoreDeallocCode, FailCode])
 	;
 		MaybeTraceCallLabel = no,
 		code_gen__generate_goal(model_semi, Goal, BodyCode, !CI),
@@ -657,13 +661,8 @@
 		code_gen__generate_exit(model_semi, FrameInfo, TraceSlotInfo,
 			BodyContext, RestoreDeallocCode, ExitCode, !CI),
 		code_info__generate_resume_point(ResumePoint, ResumeCode, !CI),
-		Code =
-			tree(EntryCode,
-			tree(BodyCode,
-			tree(ExitCode,
-			tree(ResumeCode,
-			tree(RestoreDeallocCode,
-			     FailCode)))))
+		Code = tree_list([EntryCode, BodyCode, ExitCode,
+			ResumeCode, RestoreDeallocCode, FailCode])
 	).
 
 generate_category_code(model_non, Goal, ResumePoint, TraceSlotInfo, Code,
@@ -706,9 +705,9 @@
 			TraceFailCode = empty
 		),
 		( TraceSlotInfo ^ slot_trail = yes(_) ->
-			( TraceSlotInfo ^ slot_from_full =
-				yes(FromFullSlot)
-			->
+			MaybeFromFull = TraceSlotInfo ^ slot_from_full,
+			(
+				MaybeFromFull = yes(FromFullSlot),
 				%
 				% Generate code which discards the ticket
 				% only if it was allocated, i.e. only if
@@ -726,6 +725,7 @@
 					label(SkipLabel) - ""
 				])
 			;
+				MaybeFromFull = no,
 				DiscardTraceTicketCode = node([
 					discard_ticket - "discard retry ticket"
 				])
@@ -736,15 +736,9 @@
 		FailCode = node([
 			goto(do_fail) - "fail after fail trace port"
 		]),
-		Code =
-			tree(EntryCode,
-			tree(TraceCallCode,
-			tree(BodyCode,
-			tree(ExitCode,
-			tree(ResumeCode,
-			tree(TraceFailCode,
-			tree(DiscardTraceTicketCode,
-			     FailCode)))))))
+		Code = tree_list([EntryCode, TraceCallCode, BodyCode,
+			ExitCode, ResumeCode, TraceFailCode,
+			DiscardTraceTicketCode, FailCode])
 	;
 		MaybeTraceCallLabel = no,
 		code_gen__generate_goal(model_non, Goal, BodyCode, !CI),
@@ -752,10 +746,7 @@
 			FrameInfo, EntryCode),
 		code_gen__generate_exit(model_non, FrameInfo, TraceSlotInfo,
 			BodyContext, _, ExitCode, !CI),
-		Code =
-			tree(EntryCode,
-			tree(BodyCode,
-			     ExitCode))
+		Code = tree_list([EntryCode, BodyCode, ExitCode])
 	).
 
 %---------------------------------------------------------------------------%
@@ -820,9 +811,11 @@
 		MaybeSuccipSlot = no
 	),
 	code_info__get_maybe_trace_info(CI, MaybeTraceInfo),
-	( MaybeTraceInfo = yes(TraceInfo) ->
+	(
+		MaybeTraceInfo = yes(TraceInfo),
 		trace__generate_slot_fill_code(CI, TraceInfo, TraceFillCode)
 	;
+		MaybeTraceInfo = no,
 		TraceFillCode = empty
 	),
 	module_info_pred_info(ModuleInfo, PredId, PredInfo),
@@ -837,7 +830,7 @@
 		(
 			Goal = foreign_proc(_, _, _, _, _, PragmaCode) - _,
 			PragmaCode = nondet(Fields, FieldsContext,
-				_,_,_,_,_,_,_)
+				_, _, _, _, _, _, _)
 		->
 			pragma_c_gen__struct_name(ModuleName, PredName,
 				Arity, ProcId, StructName),
@@ -883,13 +876,8 @@
 	EndComment = node([
 		comment("End of procedure prologue") - ""
 	]),
-	EntryCode =
-		tree(StartComment,
-		tree(LabelCode,
-		tree(AllocCode,
-		tree(SaveSuccipCode,
-		tree(TraceFillCode,
-		     EndComment))))).
+	EntryCode = tree_list([StartComment, LabelCode, AllocCode,
+		SaveSuccipCode, TraceFillCode, EndComment]).
 
 %---------------------------------------------------------------------------%
 
@@ -945,10 +933,7 @@
 				- ""
 		]),
 		RestoreDeallocCode = empty,	% always empty for nondet code
-		ExitCode =
-			tree(StartComment,
-			tree(UndefCode,
-			     EndComment))
+		ExitCode = tree_list([StartComment, UndefCode, EndComment])
 	;
 		code_info__get_instmap(!.CI, Instmap),
 		ArgModes = code_info__get_arginfo(!.CI),
@@ -961,12 +946,14 @@
 		;
 			code_info__setup_return(Args, OutLvals, FlushCode, !CI)
 		),
-		( MaybeSuccipSlot = yes(SuccipSlot) ->
+		(
+			MaybeSuccipSlot = yes(SuccipSlot),
 			RestoreSuccipCode = node([
 				assign(succip, lval(stackvar(SuccipSlot))) -
 					"restore the success ip"
 			])
 		;
+			MaybeSuccipSlot = no,
 			RestoreSuccipCode = empty
 		),
 		( ( TotalSlots = 0 ; CodeModel = model_non ) ->
@@ -980,7 +967,9 @@
 			TraceSlotInfo ^ slot_trail = yes(_),
 			CodeModel \= model_non
 		->
-			( TraceSlotInfo ^ slot_from_full = yes(FromFullSlot) ->
+			MaybeFromFull = TraceSlotInfo ^ slot_from_full,
+			(
+				MaybeFromFull = yes(FromFullSlot),
 				%
 				% Generate code which prunes the ticket
 				% only if it was allocated, i.e. only if
@@ -1013,6 +1002,7 @@
 					label(SkipLabelCopy) - ""
 				])
 			;
+				MaybeFromFull = no,
 				PruneTraceTicketCode = node([
 					prune_ticket - "prune retry ticket"
 				]),
@@ -1024,14 +1014,10 @@
 			PruneTraceTicketCodeCopy = empty
 		),
 
-		RestoreDeallocCode =
-			tree(RestoreSuccipCode,
-			tree(PruneTraceTicketCode,
-			     DeallocCode)),
-		RestoreDeallocCodeCopy =
-			tree(RestoreSuccipCode,
-			tree(PruneTraceTicketCodeCopy,
-			     DeallocCode)),
+		RestoreDeallocCode = tree_list([RestoreSuccipCode,
+			PruneTraceTicketCode, DeallocCode]),
+		RestoreDeallocCodeCopy = tree_list([RestoreSuccipCode,
+			PruneTraceTicketCodeCopy, DeallocCode]),
 
 		code_info__get_maybe_trace_info(!.CI, MaybeTraceInfo),
 		(
@@ -1061,8 +1047,7 @@
 				)
 			),
 			solutions(FindBaseLvals, TypeInfoLvals),
-			set__insert_list(OutLvals, TypeInfoLvals,
-				LiveLvals)
+			set__insert_list(OutLvals, TypeInfoLvals, LiveLvals)
 		;
 			MaybeTraceInfo = no,
 			TraceExitCode = empty,
@@ -1075,10 +1060,8 @@
 				livevals(LiveLvals) - "",
 				goto(succip) - "Return from procedure call"
 			]),
-			AllSuccessCode =
-				tree(TraceExitCode,
-				tree(RestoreDeallocCodeCopy,
-				     SuccessCode))
+			AllSuccessCode = tree_list([TraceExitCode,
+				RestoreDeallocCodeCopy, SuccessCode])
 		;
 			CodeModel = model_semi,
 			set__insert(LiveLvals, reg(r, 1), SuccessLiveRegs),
@@ -1087,16 +1070,16 @@
 				livevals(SuccessLiveRegs) - "",
 				goto(succip) - "Return from procedure call"
 			]),
-			AllSuccessCode =
-				tree(TraceExitCode,
-				tree(RestoreDeallocCodeCopy,
-				     SuccessCode))
+			AllSuccessCode = tree_list([TraceExitCode,
+				RestoreDeallocCodeCopy, SuccessCode])
 		;
 			CodeModel = model_non,
-			( MaybeTraceInfo = yes(TraceInfo2) ->
+			(
+				MaybeTraceInfo = yes(TraceInfo2),
 				trace__maybe_setup_redo_event(TraceInfo2,
 					SetupRedoCode)
 			;
+				MaybeTraceInfo = no,
 				SetupRedoCode = empty
 			),
 			SuccessCode = node([
@@ -1104,16 +1087,11 @@
 				goto(do_succeed(no))
 					- "Return from procedure call"
 			]),
-			AllSuccessCode =
-				tree(SetupRedoCode,
-				tree(TraceExitCode,
-				     SuccessCode))
-		),
-		ExitCode =
-			tree(StartComment,
-			tree(FlushCode,
-			tree(AllSuccessCode,
-			     EndComment)))
+			AllSuccessCode = tree_list([SetupRedoCode,
+				TraceExitCode, SuccessCode])
+		),
+		ExitCode = tree_list([StartComment, FlushCode, AllSuccessCode,
+			EndComment])
 	).
 
 %---------------------------------------------------------------------------%
@@ -1318,36 +1296,14 @@
 	code_tree::out, code_info::in, code_info::out) is det.
 
 code_gen__generate_goals([], _, empty, !CI).
-code_gen__generate_goals([Goal | Goals], CodeModel, Instr, !CI) :-
-	code_gen__generate_goal(CodeModel, Goal, Instr1, !CI),
+code_gen__generate_goals([Goal | Goals], CodeModel, Code, !CI) :-
+	code_gen__generate_goal(CodeModel, Goal, Code1, !CI),
 	code_info__get_instmap(!.CI, Instmap),
-	(
-		instmap__is_unreachable(Instmap)
-	->
-		Instr = Instr1
-	;
-		code_gen__generate_goals(Goals, CodeModel, Instr2, !CI),
-		Instr = tree(Instr1, Instr2)
-	).
-
-%---------------------------------------------------------------------------%
-
-:- pred code_gen__select_args_with_mode(assoc_list(prog_var, arg_info)::in,
-	arg_mode::in, list(prog_var)::out, list(lval)::out) is det.
-
-code_gen__select_args_with_mode([], _, [], []).
-code_gen__select_args_with_mode([Var - ArgInfo | Args], DesiredMode, Vs, Ls) :-
-	code_gen__select_args_with_mode(Args, DesiredMode, Vs0, Ls0),
-	ArgInfo = arg_info(Loc, Mode),
-	(
-		Mode = DesiredMode
-	->
-		code_util__arg_loc_to_register(Loc, Reg),
-		Vs = [Var | Vs0],
-		Ls = [Reg | Ls0]
+	( instmap__is_unreachable(Instmap) ->
+		Code = Code1
 	;
-		Vs = Vs0,
-		Ls = Ls0
+		code_gen__generate_goals(Goals, CodeModel, Code2, !CI),
+		Code = tree(Code1, Code2)
 	).
 
 %---------------------------------------------------------------------------%
Index: compiler/code_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/code_info.m,v
retrieving revision 1.296
diff -u -b -r1.296 code_info.m
--- compiler/code_info.m	21 Jan 2005 03:27:35 -0000	1.296
+++ compiler/code_info.m	19 Mar 2005 05:05:48 -0000
@@ -44,7 +44,14 @@
 :- import_module mdbcomp__prim_data.
 :- import_module parse_tree__prog_data.
 
-:- import_module bool, set, list, map, std_util, assoc_list, counter, term.
+:- import_module assoc_list.
+:- import_module bool.
+:- import_module counter.
+:- import_module list.
+:- import_module map.
+:- import_module set.
+:- import_module std_util.
+:- import_module term.
 
 :- implementation.
 
@@ -63,9 +70,13 @@
 :- import_module parse_tree__prog_out.
 :- import_module parse_tree__prog_type.
 
+:- import_module char.
+:- import_module int.
+:- import_module require.
+:- import_module set.
+:- import_module stack.
+:- import_module string.
 :- import_module varset.
-:- import_module set, stack.
-:- import_module string, require, char, int.
 
 %---------------------------------------------------------------------------%
 
@@ -259,30 +270,39 @@
 	code_info_static(
 		globals		:: globals,
 				% For the code generation options.
+
 		module_info	:: module_info,
 				% The module_info structure - you just
 				% never know when you might need it.
+
 		pred_id		:: pred_id,
 				% The id of the current predicate.
+
 		proc_id		:: proc_id,
 				% The id of the current procedure.
+
 		proc_info	:: proc_info,
 				% The proc_info for this procedure.
+
 		pred_info	:: pred_info,
 				% The pred_info for the predicate containing
 				% this procedure.
+
 		varset		:: prog_varset,
 				% The variables in this procedure.
+
 		var_slot_count	:: int,
 				% The number of stack slots allocated.
 				% for storing variables.
 				% (Some extra stack slots are used
 				% for saving and restoring registers.)
+
 		maybe_trace_info :: maybe(trace_info),
 				% Information about which stack slots
 				% the call sequence number and depth
 				% are stored in, provided tracing is
 				% switched on.
+
 		opt_no_resume_calls :: bool
 	).
 
@@ -291,16 +311,20 @@
 		forward_live_vars :: set(prog_var),
 				% Variables that are forward live
 				% after this goal.
+
  		instmap		:: instmap,
 				% Current insts of the live variables.
+
 		zombies		:: set(prog_var),
 				% Zombie variables; variables that are not
 				% forward live but which are protected by
 				% an enclosing resume point.
+
 		var_locn_info	:: var_locn_info,
 				% A map storing the information about
 				% the status of each known variable.
 				% (Known vars = forward live vars + zombies)
+
 		temps_in_use	:: set(lval),
 				% The set of temporary locations currently in
 				% use. These lvals must be all be keys in the
@@ -308,6 +332,7 @@
 				% is one of the persistent fields below. Any
 				% keys in that map which are not in this set
 				% are free for reuse.
+
 		fail_info	:: fail_info
 				% Information about how to manage failures.
 	).
@@ -317,16 +342,20 @@
  		label_num_src	:: counter,
 				% Counter for the local labels used
 				% by this procedure.
+
 		store_succip	:: bool,
 				% do we need to store succip?
+
 		label_info	:: proc_label_layout_info,
 				% Information on which values
 				% are live and where at which labels,
 				% for tracing and/or accurate gc.
+
 		stackslot_max	:: int,
 				% The maximum number of extra
 				% temporary stackslots that have been
 				% used during the procedure.
+
 		temp_contents	:: map(lval, slot_contents),
 				% The temporary locations that have ever been
 				% used on the stack, and what they contain.
@@ -338,10 +367,13 @@
 				% which would make it impossible to describe
 				% to gc what the slot contains after the end
 				% of the branched control structure.
+
 		closure_layout_seq :: counter,
+
 		closure_layouts	:: list(comp_gen_c_data),
 				% Closure layout structures generated by this
 				% procedure.
+
 		max_reg_used	:: int,
 				% At each call to MR_trace, we compute the
 				% highest rN register number that contains
@@ -352,9 +384,11 @@
 				% are equal to or smaller than this field.
 				% This slot contains -1 if tracing is not
 				% enabled.
+
 		created_temp_frame:: bool,
 				% True iff the procedure has created one or
 				% more temporary nondet frames.
+
 		static_cell_info :: static_cell_info
 	).
 
@@ -852,9 +886,10 @@
 	),
 	( map__search(Internals0, LabelNum, Internal0) ->
 		Internal0 = internal_layout_info(Exec0, Resume, Return),
-		( Exec0 = no ->
-			true
+		(
+			Exec0 = no
 		;
+			Exec0 = yes(_),
 			error("adding trace layout for already known label")
 		),
 		Internal = internal_layout_info(Exec, Resume, Return),
@@ -876,9 +911,10 @@
 	),
 	( map__search(Internals0, LabelNum, Internal0) ->
 		Internal0 = internal_layout_info(Exec, Resume0, Return),
-		( Resume0 = no ->
-			true
+		(
+			Resume0 = no
 		;
+			Resume0 = yes(_),
 			error("adding gc layout for already known label")
 		),
 		Internal = internal_layout_info(Exec, Resume, Return),
@@ -1980,19 +2016,11 @@
 	SuccLabelCode = node([
 		label(SuccLabel) - "Success continuation"
 	]),
-	SuccessCode =
-		tree(SuccessUndoCode,
-		     CommitTrailCode),
-	FailureCode =
-		tree(ResumePointCode,
-		tree(FailureUndoCode,
-		tree(RestoreTrailCode,
-		     FailCode))),
-	Code =
-		tree(SuccessCode,
-		tree(GotoSuccLabel,
-		tree(FailureCode,
-		     SuccLabelCode))).
+	SuccessCode = tree(SuccessUndoCode, CommitTrailCode),
+	FailureCode = tree_list([ResumePointCode, FailureUndoCode,
+		RestoreTrailCode, FailCode]),
+	Code = tree_list([SuccessCode, GotoSuccLabel,
+		FailureCode, SuccLabelCode]).
 
 %---------------------------------------------------------------------------%
 
@@ -2594,7 +2622,8 @@
 code_info__maybe_save_trail_info(MaybeTrailSlots, SaveTrailCode, !CI) :-
 	code_info__get_globals(!.CI, Globals),
 	globals__lookup_bool_option(Globals, use_trail, UseTrail),
-	( UseTrail = yes ->
+	(
+		UseTrail = yes,
 		code_info__acquire_temp_slot(ticket_counter, CounterSlot, !CI),
 		code_info__acquire_temp_slot(ticket, TrailPtrSlot, !CI),
 		MaybeTrailSlots = yes(CounterSlot - TrailPtrSlot),
@@ -2605,6 +2634,7 @@
 				- "save the trail pointer"
 		])
 	;
+		UseTrail = no,
 		MaybeTrailSlots = no,
 		SaveTrailCode = empty
 	).
@@ -2624,7 +2654,8 @@
 			reset_ticket(lval(TrailPtrSlot), commit)
 				- "discard trail entries and restore trail ptr",
 			prune_tickets_to(lval(CounterSlot))
-				- "restore ticket counter (but not high water mark)"
+				- ("restore ticket counter " ++
+				"(but not high water mark)")
 		]),
 		RestoreCode = node([
 			reset_ticket(lval(TrailPtrSlot), undo)
@@ -2891,32 +2922,39 @@
 %---------------------------------------------------------------------------%
 
 code_info__maybe_save_hp(Maybe, Code, MaybeHpSlot, !CI) :-
-	( Maybe = yes ->
+	(
+		Maybe = yes,
 		code_info__save_hp(Code, HpSlot, !CI),
 		MaybeHpSlot = yes(HpSlot)
 	;
+		Maybe = no,
 		Code = empty,
 		MaybeHpSlot = no
 	).
 
 code_info__maybe_restore_hp(MaybeHpSlot, Code) :-
-	( MaybeHpSlot = yes(HpSlot) ->
+	(
+		MaybeHpSlot = yes(HpSlot),
 		code_info__restore_hp(HpSlot, Code)
 	;
+		MaybeHpSlot = no,
 		Code = empty
 	).
 
 code_info__maybe_release_hp(MaybeHpSlot, !CI) :-
-	( MaybeHpSlot = yes(HpSlot) ->
+	(
+		MaybeHpSlot = yes(HpSlot),
 		code_info__release_hp(HpSlot, !CI)
 	;
-		true
+		MaybeHpSlot = no
 	).
 
 code_info__maybe_restore_and_release_hp(MaybeHpSlot, Code, !CI) :-
-	( MaybeHpSlot = yes(HpSlot) ->
+	(
+		MaybeHpSlot = yes(HpSlot),
 		code_info__restore_and_release_hp(HpSlot, Code, !CI)
 	;
+		MaybeHpSlot = no,
 		Code = empty
 	).
 
@@ -2965,57 +3003,70 @@
 %---------------------------------------------------------------------------%
 
 code_info__maybe_save_ticket(Maybe, Code, MaybeTicketSlot, !CI) :-
-	( Maybe = yes ->
+	(
+		Maybe = yes,
 		code_info__save_ticket(Code, TicketSlot, !CI),
 		MaybeTicketSlot = yes(TicketSlot)
 	;
+		Maybe = no,
 		Code = empty,
 		MaybeTicketSlot = no
 	).
 
 code_info__maybe_reset_ticket(MaybeTicketSlot, Reason, Code) :-
-	( MaybeTicketSlot = yes(TicketSlot) ->
+	(
+		MaybeTicketSlot = yes(TicketSlot),
 		code_info__reset_ticket(TicketSlot, Reason, Code)
 	;
+		MaybeTicketSlot = no,
 		Code = empty
 	).
 
 code_info__maybe_release_ticket(MaybeTicketSlot, !CI) :-
-	( MaybeTicketSlot = yes(TicketSlot) ->
+	(
+		MaybeTicketSlot = yes(TicketSlot),
 		code_info__release_ticket(TicketSlot, !CI)
 	;
-		true
+		MaybeTicketSlot = no
 	).
 
 code_info__maybe_reset_and_prune_ticket(MaybeTicketSlot, Reason, Code) :-
-	( MaybeTicketSlot = yes(TicketSlot) ->
+	(
+		MaybeTicketSlot = yes(TicketSlot),
 		code_info__reset_and_prune_ticket(TicketSlot, Reason, Code)
 	;
+		MaybeTicketSlot = no,
 		Code = empty
 	).
 
 code_info__maybe_reset_prune_and_release_ticket(MaybeTicketSlot, Reason,
 		Code, !CI) :-
-	( MaybeTicketSlot = yes(TicketSlot) ->
+	(
+		MaybeTicketSlot = yes(TicketSlot),
 		code_info__reset_prune_and_release_ticket(TicketSlot, Reason,
 			Code, !CI)
 	;
+		MaybeTicketSlot = no,
 		Code = empty
 	).
 
 code_info__maybe_reset_and_discard_ticket(MaybeTicketSlot, Reason, Code) :-
-	( MaybeTicketSlot = yes(TicketSlot) ->
+	(
+		MaybeTicketSlot = yes(TicketSlot),
 		code_info__reset_and_discard_ticket(TicketSlot, Reason, Code)
 	;
+		MaybeTicketSlot = no,
 		Code = empty
 	).
 
 code_info__maybe_reset_discard_and_release_ticket(MaybeTicketSlot, Reason,
 		Code, !CI) :-
-	( MaybeTicketSlot = yes(TicketSlot) ->
+	(
+		MaybeTicketSlot = yes(TicketSlot),
 		code_info__reset_discard_and_release_ticket(TicketSlot, Reason,
 			Code, !CI)
 	;
+		MaybeTicketSlot = no,
 		Code = empty
 	).
 
Index: compiler/code_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/code_util.m,v
retrieving revision 1.154
diff -u -b -r1.154 code_util.m
--- compiler/code_util.m	19 Jan 2005 03:10:30 -0000	1.154
+++ compiler/code_util.m	22 Mar 2005 11:12:52 -0000
@@ -25,7 +25,9 @@
 :- import_module mdbcomp__prim_data.
 :- import_module parse_tree__prog_data.
 
-:- import_module list, assoc_list, std_util.
+:- import_module assoc_list.
+:- import_module list.
+:- import_module std_util.
 
 	% Create a code address which holds the address of the specified
 	% procedure.
@@ -105,7 +107,14 @@
 :- import_module libs__options.
 :- import_module parse_tree__prog_util.
 
-:- import_module bool, char, int, string, set, term, varset, require.
+:- import_module bool.
+:- import_module char.
+:- import_module int.
+:- import_module require.
+:- import_module set.
+:- import_module string.
+:- import_module term.
+:- import_module varset.
 
 %---------------------------------------------------------------------------%
 
Index: compiler/commit_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/commit_gen.m,v
retrieving revision 1.5
diff -u -b -r1.5 commit_gen.m
--- compiler/commit_gen.m	23 Mar 2004 10:52:02 -0000	1.5
+++ compiler/commit_gen.m	22 Mar 2005 11:13:52 -0000
@@ -29,44 +29,53 @@
 :- import_module libs__tree.
 :- import_module ll_backend__code_gen.
 
-:- import_module std_util, require.
+:- import_module require.
+:- import_module std_util.
 
-commit_gen__generate_commit(OuterCodeModel, Goal, Code) -->
-	{ Goal = _ - InnerGoalInfo },
-	{ goal_info_get_code_model(InnerGoalInfo, InnerCodeModel) },
+commit_gen__generate_commit(OuterCodeModel, Goal, Code, !Info) :-
+	Goal = _ - InnerGoalInfo,
+	goal_info_get_code_model(InnerGoalInfo, InnerCodeModel),
 	(
-		{ OuterCodeModel = model_det },
+		OuterCodeModel = model_det,
 		(
-			{ InnerCodeModel = model_det },
-			code_gen__generate_goal(InnerCodeModel, Goal, Code)
+			InnerCodeModel = model_det,
+			code_gen__generate_goal(InnerCodeModel, Goal, Code,
+				!Info)
 		;
-			{ InnerCodeModel = model_semi },
-			{ error("semidet model in det context") }
+			InnerCodeModel = model_semi,
+			error("semidet model in det context")
 		;
-			{ InnerCodeModel = model_non },
+			InnerCodeModel = model_non,
 			code_info__prepare_for_det_commit(CommitInfo,
-				PreCommit),
-			code_gen__generate_goal(InnerCodeModel, Goal, GoalCode),
-			code_info__generate_det_commit(CommitInfo, Commit),
-			{ Code = tree(PreCommit, tree(GoalCode, Commit)) }
+				PreCommit, !Info),
+			code_gen__generate_goal(InnerCodeModel, Goal, GoalCode,
+				!Info),
+			code_info__generate_det_commit(CommitInfo, Commit,
+				!Info),
+			Code = tree(PreCommit, tree(GoalCode, Commit))
 		)
 	;
-		{ OuterCodeModel = model_semi },
+		OuterCodeModel = model_semi,
 		(
-			{ InnerCodeModel = model_det },
-			code_gen__generate_goal(InnerCodeModel, Goal, Code)
+			InnerCodeModel = model_det,
+			code_gen__generate_goal(InnerCodeModel, Goal, Code,
+				!Info)
+		;
+			InnerCodeModel = model_semi,
+			code_gen__generate_goal(InnerCodeModel, Goal, Code,
+				!Info)
 		;
-			{ InnerCodeModel = model_semi },
-			code_gen__generate_goal(InnerCodeModel, Goal, Code)
-		;
-			{ InnerCodeModel = model_non },
+			InnerCodeModel = model_non,
 			code_info__prepare_for_semi_commit(CommitInfo,
-				PreCommit),
-			code_gen__generate_goal(InnerCodeModel, Goal, GoalCode),
-			code_info__generate_semi_commit(CommitInfo, Commit),
-			{ Code = tree(PreCommit, tree(GoalCode, Commit)) }
+				PreCommit,
+					!Info),
+			code_gen__generate_goal(InnerCodeModel, Goal, GoalCode,
+				!Info),
+			code_info__generate_semi_commit(CommitInfo, Commit,
+				!Info),
+			Code = tree(PreCommit, tree(GoalCode, Commit))
 		)
 	;
-		{ OuterCodeModel = model_non },
-		code_gen__generate_goal(InnerCodeModel, Goal, Code)
+		OuterCodeModel = model_non,
+		code_gen__generate_goal(InnerCodeModel, Goal, Code, !Info)
 	).
Index: compiler/common.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/common.m,v
retrieving revision 1.76
diff -u -b -r1.76 common.m
--- compiler/common.m	6 Mar 2005 05:17:27 -0000	1.76
+++ compiler/common.m	22 Mar 2005 11:15:15 -0000
@@ -99,8 +99,16 @@
 :- import_module parse_tree__prog_type.
 :- import_module transform_hlds__pd_cost.
 
-:- import_module bool, map, svmap, set, eqvclass, sveqvclass.
-:- import_module require, std_util, string, term.
+:- import_module bool.
+:- import_module eqvclass.
+:- import_module map.
+:- import_module require.
+:- import_module set.
+:- import_module std_util.
+:- import_module string.
+:- import_module sveqvclass.
+:- import_module svmap.
+:- import_module term.
 
     % The var_eqv field records information about which sets of variables
     % are known to be equivalent, usually because they have been unified.
Index: compiler/compile_target_code.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/compile_target_code.m,v
retrieving revision 1.67
diff -u -b -r1.67 compile_target_code.m
--- compiler/compile_target_code.m	21 Mar 2005 04:45:44 -0000	1.67
+++ compiler/compile_target_code.m	22 Mar 2005 11:14:11 -0000
@@ -19,7 +19,10 @@
 :- import_module libs__globals.
 :- import_module mdbcomp__prim_data.
 
-:- import_module bool, list, io, std_util.
+:- import_module bool.
+:- import_module io.
+:- import_module list.
+:- import_module std_util.
 
 	% Are we generating position independent code (for use in a
 	% shared library)? On some architectures, pic and non-pic
@@ -167,7 +170,12 @@
 :- import_module parse_tree__prog_foreign.
 :- import_module parse_tree__prog_out.
 
-:- import_module char, dir, getopt_io, int, require, string.
+:- import_module char.
+:- import_module dir.
+:- import_module getopt_io.
+:- import_module int.
+:- import_module require.
+:- import_module string.
 
 il_assemble(ErrorStream, ModuleName, HasMain, Succeeded, !IO) :-
 	module_name_to_file_name(ModuleName, ".il", no, IL_File, !IO),
Index: compiler/complexity.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/complexity.m,v
retrieving revision 1.1
diff -u -b -r1.1 complexity.m
--- compiler/complexity.m	15 Feb 2005 05:22:16 -0000	1.1
+++ compiler/complexity.m	22 Mar 2005 11:15:32 -0000
@@ -19,7 +19,8 @@
 :- import_module hlds__hlds_module.
 :- import_module hlds__hlds_pred.
 
-:- import_module std_util, io.
+:- import_module io.
+:- import_module std_util.
 
 	% read_spec_file(FileName, MaybeNumLinesProcMap, !IO):
 	% Try to read in a complexity proc map from FileName. If successful,
@@ -71,8 +72,16 @@
 :- import_module transform_hlds__term_norm.
 :- import_module mdbcomp__prim_data.
 
-:- import_module bool, int, string, list, set, map, assoc_list.
-:- import_module varset, term, require.
+:- import_module assoc_list.
+:- import_module bool.
+:- import_module int.
+:- import_module list.
+:- import_module map.
+:- import_module require.
+:- import_module set.
+:- import_module string.
+:- import_module term.
+:- import_module varset.
 
 read_spec_file(FileName, MaybeNumLinesProcMap, !IO) :-
 	io__open_input(FileName, ResStream, !IO),
Index: compiler/const_prop.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/const_prop.m,v
retrieving revision 1.26
diff -u -b -r1.26 const_prop.m
--- compiler/const_prop.m	19 Jan 2005 03:10:31 -0000	1.26
+++ compiler/const_prop.m	22 Mar 2005 11:15:40 -0000
@@ -64,8 +64,14 @@
 :- import_module mdbcomp__prim_data.
 :- import_module parse_tree__prog_data.
 
-:- import_module bool, list, int, float, map, require, string.
+:- import_module bool.
+:- import_module float.
+:- import_module int.
+:- import_module list.
+:- import_module map.
+:- import_module require.
 :- import_module std_util.
+:- import_module string.
 
 %------------------------------------------------------------------------------%
 
Index: compiler/constraint.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/constraint.m,v
retrieving revision 1.58
diff -u -b -r1.58 constraint.m
--- compiler/constraint.m	16 Oct 2004 15:05:51 -0000	1.58
+++ compiler/constraint.m	22 Mar 2005 11:15:47 -0000
@@ -58,8 +58,15 @@
 :- import_module libs__globals.
 :- import_module libs__options.
 
-:- import_module assoc_list, list, require, set, map, std_util.
-:- import_module string, term, varset.
+:- import_module assoc_list.
+:- import_module list.
+:- import_module map.
+:- import_module require.
+:- import_module set.
+:- import_module std_util.
+:- import_module string.
+:- import_module term.
+:- import_module varset.
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/context.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/context.m,v
retrieving revision 1.10
diff -u -b -r1.10 context.m
--- compiler/context.m	19 Jan 2005 03:10:31 -0000	1.10
+++ compiler/context.m	22 Mar 2005 11:16:54 -0000
@@ -57,7 +57,14 @@
 :- import_module hlds__instmap.
 :- import_module mdbcomp__prim_data.
 
-:- import_module assoc_list, bool, map, require, set, std_util, term, varset.
+:- import_module assoc_list.
+:- import_module bool.
+:- import_module map.
+:- import_module require.
+:- import_module set.
+:- import_module std_util.
+:- import_module term.
+:- import_module varset.
 
 context__process_disjuncts(OldPredProcId, Inputs, Outputs,
 		Disjuncts0, Disjuncts) -->
Index: compiler/continuation_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/continuation_info.m,v
retrieving revision 1.57
diff -u -b -r1.57 continuation_info.m
--- compiler/continuation_info.m	21 Jan 2005 03:27:36 -0000	1.57
+++ compiler/continuation_info.m	22 Mar 2005 11:18:52 -0000
@@ -64,7 +64,12 @@
 :- import_module mdbcomp__prim_data.
 :- import_module parse_tree__prog_data.
 
-:- import_module bool, std_util, list, assoc_list, set, map.
+:- import_module assoc_list.
+:- import_module bool.
+:- import_module list.
+:- import_module map.
+:- import_module set.
+:- import_module std_util.
 
 	%
 	% Information for any procedure, includes information about the
@@ -355,32 +360,38 @@
 :- import_module ll_backend__code_util.
 :- import_module parse_tree__prog_type.
 
-:- import_module int, string, require, term, varset.
+:- import_module int.
+:- import_module require.
+:- import_module string.
+:- import_module term.
+:- import_module varset.
 
 %-----------------------------------------------------------------------------%
 
 	% Exported predicates.
 
-continuation_info__maybe_process_llds([], _) --> [].
-continuation_info__maybe_process_llds([Proc | Procs], ModuleInfo) -->
-	{ Proc = c_procedure(_, _, PredProcId, Instrs, _, _, _) },
+continuation_info__maybe_process_llds([], _, !GlobalData).
+continuation_info__maybe_process_llds([Proc | Procs], ModuleInfo,
+		!GlobalData) :-
+	Proc = c_procedure(_, _, PredProcId, Instrs, _, _, _),
 	continuation_info__maybe_process_proc_llds(Instrs, PredProcId,
-		ModuleInfo),
-	continuation_info__maybe_process_llds(Procs, ModuleInfo).
+		ModuleInfo, !GlobalData),
+	continuation_info__maybe_process_llds(Procs, ModuleInfo, !GlobalData).
 
 continuation_info__maybe_process_proc_llds(Instructions, PredProcId,
-		ModuleInfo, ContInfo0, ContInfo) :-
+		ModuleInfo, !ContInfo) :-
 	PredProcId = proc(PredId, _),
 	module_info_pred_info(ModuleInfo, PredId, PredInfo),
 	module_info_globals(ModuleInfo, Globals),
 	continuation_info__basic_stack_layout_for_proc(PredInfo, Globals,
 		Layout, _),
-	( Layout = yes ->
+	(
+		Layout = yes,
 		globals__want_return_var_layouts(Globals, WantReturnLayout),
 		continuation_info__process_proc_llds(PredProcId, Instructions,
-			WantReturnLayout, ContInfo0, ContInfo)
+			WantReturnLayout, !ContInfo)
 	;
-		ContInfo = ContInfo0
+		Layout = no
 	).
 
 :- type call_info
@@ -433,7 +444,7 @@
 	proc_label_layout_info::in, proc_label_layout_info::out) is det.
 
 continuation_info__process_continuation(WantReturnInfo, CallInfo,
-		Internals0, Internals) :-
+		!Internals) :-
 	CallInfo = call_info(ReturnLabel, Target, LiveInfoList,
 		Context, MaybeGoalPath),
 	% We could check not only that the return label is an internal label,
@@ -445,7 +456,7 @@
 		ReturnLabel = entry(_, _),
 		error("continuation_info__process_continuation: bad return")
 	),
-	( map__search(Internals0, ReturnLabelNum, Internal0) ->
+	( map__search(!.Internals, ReturnLabelNum, Internal0) ->
 		Internal0 = internal_layout_info(Port0, Resume0, Return0)
 	;
 		Port0 = no,
@@ -485,7 +496,7 @@
 		Return = Return0
 	),
 	Internal = internal_layout_info(Port0, Resume0, Return),
-	map__set(Internals0, ReturnLabelNum, Internal, Internals).
+	map__set(!.Internals, ReturnLabelNum, Internal, !:Internals).
 
 :- pred continuation_info__convert_return_data(list(liveinfo)::in,
 	set(layout_var_info)::out, map(tvar, set(layout_locn))::out) is det.
Index: compiler/cse_detection.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/cse_detection.m,v
retrieving revision 1.79
diff -u -b -r1.79 cse_detection.m
--- compiler/cse_detection.m	14 Jun 2004 04:15:59 -0000	1.79
+++ compiler/cse_detection.m	22 Mar 2005 11:19:02 -0000
@@ -50,9 +50,18 @@
 :- import_module libs__options.
 :- import_module parse_tree__prog_data.
 
-:- import_module term, varset.
-:- import_module int, string, bool, list, assoc_list, map, multi_map.
-:- import_module set, std_util, require.
+:- import_module assoc_list.
+:- import_module bool.
+:- import_module int.
+:- import_module list.
+:- import_module map.
+:- import_module multi_map.
+:- import_module require.
+:- import_module set.
+:- import_module std_util.
+:- import_module string.
+:- import_module term.
+:- import_module varset.
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/dead_proc_elim.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/dead_proc_elim.m,v
retrieving revision 1.95
diff -u -b -r1.95 dead_proc_elim.m
--- compiler/dead_proc_elim.m	21 Jan 2005 06:20:36 -0000	1.95
+++ compiler/dead_proc_elim.m	22 Mar 2005 11:19:20 -0000
@@ -24,7 +24,9 @@
 :- import_module hlds__hlds_pred.
 :- import_module mdbcomp__prim_data.
 
-:- import_module map, std_util, io.
+:- import_module io.
+:- import_module map.
+:- import_module std_util.
 
 :- type dead_proc_pass
 	--->	warning_pass
@@ -72,7 +74,13 @@
 :- import_module parse_tree__prog_data.
 :- import_module parse_tree__prog_util.
 
-:- import_module int, string, list, set, queue, bool, require.
+:- import_module bool.
+:- import_module int.
+:- import_module list.
+:- import_module queue.
+:- import_module require.
+:- import_module set.
+:- import_module string.
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/deep_profiling.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/deep_profiling.m,v
retrieving revision 1.31
diff -u -b -r1.31 deep_profiling.m
--- compiler/deep_profiling.m	21 Jan 2005 03:27:36 -0000	1.31
+++ compiler/deep_profiling.m	22 Mar 2005 11:19:34 -0000
@@ -45,8 +45,18 @@
 :- import_module transform_hlds.
 :- import_module transform_hlds__dependency_graph.
 
-:- import_module bool, int, list, assoc_list, map, require, set.
-:- import_module std_util, string, term, varset, counter.
+:- import_module assoc_list.
+:- import_module bool.
+:- import_module counter.
+:- import_module int.
+:- import_module list.
+:- import_module map.
+:- import_module require.
+:- import_module set.
+:- import_module std_util.
+:- import_module string.
+:- import_module term.
+:- import_module varset.
 
 apply_deep_profiling_transformation(!ModuleInfo) :-
 	module_info_globals(!.ModuleInfo, Globals),
Index: compiler/deforest.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/deforest.m,v
retrieving revision 1.46
diff -u -b -r1.46 deforest.m
--- compiler/deforest.m	7 Feb 2005 15:10:32 -0000	1.46
+++ compiler/deforest.m	22 Mar 2005 11:20:00 -0000
@@ -76,8 +76,18 @@
 :- import_module transform_hlds__pd_term.
 :- import_module transform_hlds__pd_util.
 
-:- import_module assoc_list, bool, getopt_io, int, list, map, require.
-:- import_module set, std_util, string, term, varset.
+:- import_module assoc_list.
+:- import_module bool.
+:- import_module getopt_io.
+:- import_module int.
+:- import_module list.
+:- import_module map.
+:- import_module require.
+:- import_module set.
+:- import_module std_util.
+:- import_module string.
+:- import_module term.
+:- import_module varset.
 
 deforestation(!ModuleInfo, !IO) :-
 	proc_arg_info_init(ProcArgInfo0),
Index: compiler/delay_construct.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/delay_construct.m,v
retrieving revision 1.8
diff -u -b -r1.8 delay_construct.m
--- compiler/delay_construct.m	14 Jun 2004 04:16:00 -0000	1.8
+++ compiler/delay_construct.m	22 Mar 2005 11:20:10 -0000
@@ -29,6 +29,7 @@
 
 :- import_module hlds__hlds_module.
 :- import_module hlds__hlds_pred.
+
 :- import_module io.
 
 :- pred delay_construct_proc(pred_id::in, proc_id::in, module_info::in,
@@ -46,7 +47,11 @@
 :- import_module libs__globals.
 :- import_module parse_tree__prog_data.
 
-:- import_module bool, list, set, std_util, require.
+:- import_module bool.
+:- import_module list.
+:- import_module require.
+:- import_module set.
+:- import_module std_util.
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/delay_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/delay_info.m,v
retrieving revision 1.21
diff -u -b -r1.21 delay_info.m
--- compiler/delay_info.m	23 Dec 2004 06:49:15 -0000	1.21
+++ compiler/delay_info.m	22 Mar 2005 11:20:22 -0000
@@ -91,7 +91,13 @@
 :- import_module check_hlds__mode_errors.	% for the mode_error_info
 						% and delay_info types.
 
-:- import_module int, stack, set, map, svmap, require, std_util.
+:- import_module int.
+:- import_module map.
+:- import_module require.
+:- import_module set.
+:- import_module stack.
+:- import_module std_util.
+:- import_module svmap.
 
 	% The delay_info structure is a tangled web of substructures
 	% all of which are pointing at each other - debugging it
Index: compiler/delay_slot.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/delay_slot.m,v
retrieving revision 1.10
diff -u -b -r1.10 delay_slot.m
--- compiler/delay_slot.m	31 Mar 2004 08:37:04 -0000	1.10
+++ compiler/delay_slot.m	22 Mar 2005 11:20:32 -0000
@@ -59,7 +59,8 @@
 
 :- implementation.
 
-:- import_module string, std_util.
+:- import_module std_util.
+:- import_module string.
 
 fill_branch_delay_slot([], []).
 fill_branch_delay_slot([Instr0 | Instrs0], Instrs) :-
Index: compiler/dense_switch.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/dense_switch.m,v
retrieving revision 1.49
diff -u -b -r1.49 dense_switch.m
--- compiler/dense_switch.m	14 Jun 2004 04:16:00 -0000	1.49
+++ compiler/dense_switch.m	22 Mar 2005 11:20:49 -0000
@@ -57,10 +57,16 @@
 :- import_module hlds__hlds_goal.
 :- import_module hlds__hlds_llds.
 :- import_module hlds__hlds_module.
+:- import_module libs__tree.
 :- import_module ll_backend__code_gen.
 :- import_module ll_backend__trace.
 
-:- import_module char, map, libs__tree, int, std_util, require, list.
+:- import_module char.
+:- import_module int.
+:- import_module list.
+:- import_module map.
+:- import_module require.
+:- import_module std_util.
 
 dense_switch__is_dense_switch(CI, CaseVar, TaggedCases, CanFail0, ReqDensity,
 		FirstVal, LastVal, CanFail) :-
Index: compiler/dependency_graph.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/dependency_graph.m,v
retrieving revision 1.74
diff -u -b -r1.74 dependency_graph.m
--- compiler/dependency_graph.m	19 Jan 2005 03:10:32 -0000	1.74
+++ compiler/dependency_graph.m	22 Mar 2005 11:21:02 -0000
@@ -24,7 +24,9 @@
 :- import_module hlds__hlds_module.
 :- import_module hlds__hlds_pred.
 
-:- import_module bool, list, io.
+:- import_module bool.
+:- import_module io.
+:- import_module list.
 
 	% Ensure that the module_info contains a version of the
 	% dependency_info which only contains arcs between procedures
@@ -111,10 +113,20 @@
 :- import_module parse_tree__mercury_to_mercury.
 :- import_module parse_tree__prog_data.
 
-:- import_module term, varset.
-:- import_module int, bool, term, require, string.
-:- import_module map, multi_map, set, std_util.
-:- import_module varset, relation, eqvclass.
+:- import_module bool.
+:- import_module eqvclass.
+:- import_module int.
+:- import_module map.
+:- import_module multi_map.
+:- import_module relation.
+:- import_module require.
+:- import_module set.
+:- import_module std_util.
+:- import_module string.
+:- import_module term.
+:- import_module term.
+:- import_module varset.
+:- import_module varset.
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/det_analysis.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/det_analysis.m,v
retrieving revision 1.173
diff -u -b -r1.173 det_analysis.m
--- compiler/det_analysis.m	6 Jan 2005 04:30:54 -0000	1.173
+++ compiler/det_analysis.m	22 Mar 2005 11:22:03 -0000
@@ -62,7 +62,9 @@
 :- import_module libs__globals.
 :- import_module parse_tree__prog_data.
 
-:- import_module list, std_util, io.
+:- import_module io.
+:- import_module list.
+:- import_module std_util.
 
 	% Perform determinism inference for local predicates with no
 	% determinism declarations, and determinism checking for all other
@@ -137,7 +139,13 @@
 :- import_module parse_tree__mercury_to_mercury.
 :- import_module parse_tree__prog_out.
 
-:- import_module string, assoc_list, bool, map, set, require, term.
+:- import_module assoc_list.
+:- import_module bool.
+:- import_module map.
+:- import_module require.
+:- import_module set.
+:- import_module string.
+:- import_module term.
 
 %-----------------------------------------------------------------------------%
 
@@ -148,9 +156,10 @@
 		!ModuleInfo),
 	globals__io_lookup_bool_option(verbose, Verbose, !IO),
 	globals__io_lookup_bool_option(debug_det, Debug, !IO),
-	( UndeclaredProcs = [] ->
-		true
+	(
+		UndeclaredProcs = []
 	;
+		UndeclaredProcs = [_ | _],
 		maybe_write_string(Verbose,
 			"% Doing determinism inference...\n", !IO),
 		global_inference_pass(!ModuleInfo, UndeclaredProcs, Debug,
@@ -206,7 +215,8 @@
 		ChangeStr = "new",
 		!:Changed = changed
 	),
-		( Debug = yes ->
+	(
+		Debug = yes,
 		io__write_string("% Inferred " ++ ChangeStr ++ " detism ",
 			!IO),
 			mercury_output_det(Detism, !IO),
@@ -215,7 +225,7 @@
 				PredId, ProcId, !IO),
 			io__write_string("\n", !IO)
 		;
-			true
+		Debug = no
 		),
 	list__append(ProcMsgs, !Msgs),
 	global_inference_single_pass(PredProcs, Debug, !ModuleInfo, !Msgs,
Index: compiler/det_report.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/det_report.m,v
retrieving revision 1.98
diff -u -b -r1.98 det_report.m
--- compiler/det_report.m	27 Jan 2005 03:38:06 -0000	1.98
+++ compiler/det_report.m	22 Mar 2005 11:22:17 -0000
@@ -20,7 +20,8 @@
 :- import_module hlds__hlds_pred.
 :- import_module parse_tree__prog_data.
 
-:- import_module io, list.
+:- import_module io.
+:- import_module list.
 
 :- type det_msg	--->
 			% warnings
@@ -152,8 +153,17 @@
 :- import_module parse_tree__prog_util.
 :- import_module parse_tree__prog_type.
 
-:- import_module assoc_list, bool, int, map, set, std_util, require, string.
-:- import_module getopt_io, term, varset.
+:- import_module assoc_list.
+:- import_module bool.
+:- import_module getopt_io.
+:- import_module int.
+:- import_module map.
+:- import_module require.
+:- import_module set.
+:- import_module std_util.
+:- import_module string.
+:- import_module term.
+:- import_module varset.
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/det_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/det_util.m,v
retrieving revision 1.28
diff -u -b -r1.28 det_util.m
--- compiler/det_util.m	21 Jan 2005 03:27:36 -0000	1.28
+++ compiler/det_util.m	22 Mar 2005 11:22:29 -0000
@@ -24,7 +24,9 @@
 :- import_module libs__globals.
 :- import_module parse_tree__prog_data.
 
-:- import_module bool, set, list.
+:- import_module bool.
+:- import_module list.
+:- import_module set.
 
 :- type maybe_changed	--->	changed ; unchanged.
 
@@ -90,7 +92,10 @@
 :- import_module parse_tree__prog_util.
 :- import_module parse_tree__prog_type.
 
-:- import_module map, term, require, std_util.
+:- import_module map.
+:- import_module require.
+:- import_module std_util.
+:- import_module term.
 
 update_instmap(_Goal0 - GoalInfo0, !InstMap) :-
 	goal_info_get_instmap_delta(GoalInfo0, DeltaInstMap),
Index: compiler/disj_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/disj_gen.m,v
retrieving revision 1.81
diff -u -b -r1.81 disj_gen.m
--- compiler/disj_gen.m	14 Jun 2004 04:16:02 -0000	1.81
+++ compiler/disj_gen.m	22 Mar 2005 11:22:44 -0000
@@ -38,11 +38,17 @@
 :- import_module libs__globals.
 :- import_module libs__options.
 :- import_module libs__tree.
+:- import_module libs__tree.
 :- import_module ll_backend__code_gen.
 :- import_module ll_backend__trace.
 :- import_module parse_tree__prog_data.
 
-:- import_module bool, set, libs__tree, map, std_util, term, require.
+:- import_module bool.
+:- import_module map.
+:- import_module require.
+:- import_module set.
+:- import_module std_util.
+:- import_module term.
 
 disj_gen__generate_disj(CodeModel, Goals, DisjGoalInfo, Code, !CI) :-
 	(
Index: compiler/dnf.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/dnf.m,v
retrieving revision 1.56
diff -u -b -r1.56 dnf.m
--- compiler/dnf.m	21 Jan 2005 06:20:37 -0000	1.56
+++ compiler/dnf.m	22 Mar 2005 11:22:58 -0000
@@ -48,7 +48,10 @@
 :- import_module hlds__hlds_module.
 :- import_module hlds__hlds_pred.
 
-:- import_module set, list, bool, std_util.
+:- import_module bool.
+:- import_module list.
+:- import_module set.
+:- import_module std_util.
 
 :- pred dnf__transform_module(bool::in, maybe(set(pred_proc_id))::in,
 	module_info::in, module_info::out) is det.
@@ -70,8 +73,16 @@
 :- import_module parse_tree__prog_data.
 :- import_module transform_hlds__dependency_graph.
 
-:- import_module require, map, list, string, int, bool, std_util, term, varset.
+:- import_module bool.
 :- import_module counter.
+:- import_module int.
+:- import_module list.
+:- import_module map.
+:- import_module require.
+:- import_module std_util.
+:- import_module string.
+:- import_module term.
+:- import_module varset.
 
 	% Traverse the module structure.
 
Index: compiler/dupelim.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/dupelim.m,v
retrieving revision 1.62
diff -u -b -r1.62 dupelim.m
--- compiler/dupelim.m	19 Jan 2005 03:10:32 -0000	1.62
+++ compiler/dupelim.m	22 Mar 2005 11:24:33 -0000
@@ -46,7 +46,8 @@
 :- import_module ll_backend__llds.
 :- import_module mdbcomp__prim_data.
 
-:- import_module list, counter.
+:- import_module counter.
+:- import_module list.
 
 :- pred dupelim_main(proc_label::in, counter::in, counter::out,
 	list(instruction)::in, list(instruction)::out) is det.
@@ -58,7 +59,12 @@
 :- import_module ll_backend__basic_block.
 :- import_module ll_backend__opt_util.
 
-:- import_module bool, std_util, assoc_list, set, map, require.
+:- import_module assoc_list.
+:- import_module bool.
+:- import_module map.
+:- import_module require.
+:- import_module set.
+:- import_module std_util.
 
 	% A std_map maps a list of standardized instructions to the list
 	% of labels whose basic blocks have that standardized form.
Index: compiler/equiv_type.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/equiv_type.m,v
retrieving revision 1.43
diff -u -b -r1.43 equiv_type.m
--- compiler/equiv_type.m	10 Mar 2005 02:35:57 -0000	1.43
+++ compiler/equiv_type.m	22 Mar 2005 12:04:27 -0000
@@ -17,7 +17,11 @@
 :- import_module parse_tree__prog_data.
 :- import_module recompilation.
 
-:- import_module bool, list, map, io, std_util.
+:- import_module bool.
+:- import_module io.
+:- import_module list.
+:- import_module map.
+:- import_module std_util.
 
 %-----------------------------------------------------------------------------%
 
@@ -98,7 +102,14 @@
 :- import_module parse_tree__prog_util.
 :- import_module parse_tree__prog_type.
 
-:- import_module assoc_list, bool, require, std_util, map, set, term, varset.
+:- import_module assoc_list.
+:- import_module bool.
+:- import_module map.
+:- import_module require.
+:- import_module set.
+:- import_module std_util.
+:- import_module term.
+:- import_module varset.
 
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
Index: compiler/equiv_type_hlds.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/equiv_type_hlds.m,v
retrieving revision 1.10
diff -u -b -r1.10 equiv_type_hlds.m
--- compiler/equiv_type_hlds.m	21 Jan 2005 06:20:37 -0000	1.10
+++ compiler/equiv_type_hlds.m	22 Mar 2005 12:04:45 -0000
@@ -38,7 +38,15 @@
 :- import_module parse_tree__prog_type.
 :- import_module recompilation.
 
-:- import_module bool, list, set, map, require, std_util, string, term, varset.
+:- import_module bool.
+:- import_module list.
+:- import_module map.
+:- import_module require.
+:- import_module set.
+:- import_module std_util.
+:- import_module string.
+:- import_module term.
+:- import_module varset.
 
 replace_in_hlds(!ModuleInfo) :-
 	module_info_types(!.ModuleInfo, Types0),
Index: compiler/error_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/error_util.m,v
retrieving revision 1.33
diff -u -b -r1.33 error_util.m
--- compiler/error_util.m	20 Mar 2005 02:24:33 -0000	1.33
+++ compiler/error_util.m	22 Mar 2005 12:05:15 -0000
@@ -38,7 +38,11 @@
 :- import_module mdbcomp__prim_data.
 :- import_module parse_tree__prog_data.
 
-:- import_module bool, char, io, list, std_util.
+:- import_module bool.
+:- import_module char.
+:- import_module io.
+:- import_module list.
+:- import_module std_util.
 
 :- type format_component
 	--->	fixed(string)	% This string should appear in the output
@@ -177,7 +181,13 @@
 :- import_module libs__globals.
 :- import_module libs__options.
 
-:- import_module io, list, term, char, string, int, require.
+:- import_module char.
+:- import_module int.
+:- import_module io.
+:- import_module list.
+:- import_module require.
+:- import_module string.
+:- import_module term.
 
 list_to_pieces([]) = [].
 list_to_pieces([Elem]) = [words(Elem)].
Index: compiler/exception_analysis.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/exception_analysis.m,v
retrieving revision 1.6
diff -u -b -r1.6 exception_analysis.m
--- compiler/exception_analysis.m	9 Feb 2005 04:51:41 -0000	1.6
+++ compiler/exception_analysis.m	22 Mar 2005 12:05:30 -0000
@@ -115,7 +115,15 @@
 :- import_module parse_tree.prog_type.
 :- import_module transform_hlds.dependency_graph.
 
-:- import_module bool, list, map, set, std_util, string, term, term_io, varset.
+:- import_module bool.
+:- import_module list.
+:- import_module map.
+:- import_module set.
+:- import_module std_util.
+:- import_module string.
+:- import_module term.
+:- import_module term_io.
+:- import_module varset.
 
 %----------------------------------------------------------------------------%
 %
Index: compiler/export.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/export.m,v
retrieving revision 1.84
diff -u -b -r1.84 export.m
--- compiler/export.m	21 Mar 2005 04:45:44 -0000	1.84
+++ compiler/export.m	22 Mar 2005 12:05:44 -0000
@@ -89,9 +89,17 @@
 :- import_module parse_tree__prog_foreign.
 :- import_module parse_tree__prog_util.
 
-:- import_module term, varset.
-:- import_module library, map, int, string, std_util, assoc_list, require.
-:- import_module list, bool.
+:- import_module assoc_list.
+:- import_module bool.
+:- import_module int.
+:- import_module library.
+:- import_module list.
+:- import_module map.
+:- import_module require.
+:- import_module std_util.
+:- import_module string.
+:- import_module term.
+:- import_module varset.
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/exprn_aux.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/exprn_aux.m,v
retrieving revision 1.54
diff -u -b -r1.54 exprn_aux.m
--- compiler/exprn_aux.m	27 Jan 2005 03:38:06 -0000	1.54
+++ compiler/exprn_aux.m	22 Mar 2005 12:06:06 -0000
@@ -12,7 +12,10 @@
 :- import_module ll_backend__llds.
 :- import_module parse_tree__prog_data.
 
-:- import_module list, std_util, bool, assoc_list.
+:- import_module assoc_list.
+:- import_module bool.
+:- import_module list.
+:- import_module std_util.
 
 :- type exprn_opts
 	--->	nlg_asm_sgt_ubf(
@@ -102,7 +105,10 @@
 :- import_module libs__globals.
 :- import_module libs__options.
 
-:- import_module int, set, require, getopt_io.
+:- import_module getopt_io.
+:- import_module int.
+:- import_module require.
+:- import_module set.
 
 exprn_aux__init_exprn_opts(Options, ExprnOpts) :-
 	getopt_io__lookup_bool_option(Options, gcc_non_local_gotos, NLG),
Index: compiler/fact_table.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/fact_table.m,v
retrieving revision 1.60
diff -u -b -r1.60 fact_table.m
--- compiler/fact_table.m	21 Mar 2005 04:45:44 -0000	1.60
+++ compiler/fact_table.m	22 Mar 2005 12:06:46 -0000
@@ -53,7 +53,8 @@
 :- import_module mdbcomp__prim_data.
 :- import_module parse_tree__prog_data.
 
-:- import_module io, list.
+:- import_module io.
+:- import_module list.
 
 	% compile the fact table into a separate .c file.
 	% fact_table_compile_facts(PredName, Arity, FileName, PredInfo0,
@@ -112,12 +113,25 @@
 :- import_module libs__options.
 
 % Standard library modules
-:- import_module int, map, std_util, assoc_list, char, require, library, bool.
-:- import_module float, math, getopt_io, string.
-:- import_module parser, term, term_io.
+:- import_module assoc_list.
+:- import_module bool.
+:- import_module char.
+:- import_module float.
+:- import_module getopt_io.
+:- import_module int.
+:- import_module library.
+:- import_module map.
+:- import_module math.
+:- import_module parser.
+:- import_module require.
+:- import_module std_util.
+:- import_module string.
+:- import_module term.
+:- import_module term_io.
 
 :- type fact_result
-	--->	ok ; error.
+	--->	ok
+	;	error.
 
 	% proc_stream contains information about an open sort file for
 	% a particular procedure.
Index: compiler/follow_code.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/follow_code.m,v
retrieving revision 1.71
diff -u -b -r1.71 follow_code.m
--- compiler/follow_code.m	30 Jun 2004 02:47:59 -0000	1.71
+++ compiler/follow_code.m	22 Mar 2005 12:06:58 -0000
@@ -41,7 +41,12 @@
 :- import_module libs__options.
 :- import_module parse_tree__prog_data.
 
-:- import_module bool, map, set, term, std_util, require.
+:- import_module bool.
+:- import_module map.
+:- import_module require.
+:- import_module set.
+:- import_module std_util.
+:- import_module term.
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/follow_vars.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/follow_vars.m,v
retrieving revision 1.69
diff -u -b -r1.69 follow_vars.m
--- compiler/follow_vars.m	7 Jun 2004 09:06:38 -0000	1.69
+++ compiler/follow_vars.m	22 Mar 2005 12:07:06 -0000
@@ -57,7 +57,14 @@
 :- import_module ll_backend__llds.
 :- import_module parse_tree__prog_data.
 
-:- import_module bool, int, list, assoc_list, map, set, std_util, require.
+:- import_module assoc_list.
+:- import_module bool.
+:- import_module int.
+:- import_module list.
+:- import_module map.
+:- import_module require.
+:- import_module set.
+:- import_module std_util.
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/foreign.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/foreign.m,v
retrieving revision 1.46
diff -u -b -r1.46 foreign.m
--- compiler/foreign.m	22 Mar 2005 01:19:37 -0000	1.46
+++ compiler/foreign.m	22 Mar 2005 12:07:25 -0000
@@ -25,7 +25,12 @@
 :- import_module mdbcomp__prim_data.
 :- import_module parse_tree__prog_data.
 
-:- import_module bool, io, list, std_util, string, term.
+:- import_module bool.
+:- import_module io.
+:- import_module list.
+:- import_module std_util.
+:- import_module string.
+:- import_module term.
 
 :- type foreign_decl_info 		== list(foreign_decl_code).
 					% in reverse order
@@ -192,8 +197,15 @@
 :- import_module parse_tree__prog_util.
 :- import_module parse_tree__prog_type.
 
-:- import_module list, map, assoc_list, std_util, string, varset, int, term.
+:- import_module assoc_list.
+:- import_module int.
+:- import_module list.
+:- import_module map.
 :- import_module require.
+:- import_module std_util.
+:- import_module string.
+:- import_module term.
+:- import_module varset.
 
 filter_decls(WantedLang, Decls0, LangDecls, NotLangDecls) :-
 	list__filter((pred(foreign_decl_code(Lang, _, _, _)::in) is semidet :-
Index: compiler/frameopt.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/frameopt.m,v
retrieving revision 1.88
diff -u -b -r1.88 frameopt.m
--- compiler/frameopt.m	19 Jan 2005 03:10:33 -0000	1.88
+++ compiler/frameopt.m	22 Mar 2005 12:07:42 -0000
@@ -94,7 +94,10 @@
 :- import_module ll_backend__llds.
 :- import_module mdbcomp__prim_data.
 
-:- import_module bool, list, set, counter.
+:- import_module bool.
+:- import_module counter.
+:- import_module list.
+:- import_module set.
 
 	% frameopt_main(ProcLabel, !LabelCounter, !Instrs,
 	%	AnyChange, NewJumps):
@@ -150,7 +153,14 @@
 :- import_module ll_backend__opt_util.
 :- import_module parse_tree__prog_data.
 
-:- import_module int, string, require, std_util, assoc_list, set, map, queue.
+:- import_module assoc_list.
+:- import_module int.
+:- import_module map.
+:- import_module queue.
+:- import_module require.
+:- import_module set.
+:- import_module std_util.
+:- import_module string.
 
 frameopt_main(ProcLabel, !C, Instrs0, Instrs, Mod, Jumps) :-
 	opt_util__get_prologue(Instrs0, LabelInstr, Comments0, Instrs1),
Index: compiler/gcc.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/gcc.m,v
retrieving revision 1.31
diff -u -b -r1.31 gcc.m
--- compiler/gcc.m	21 Jul 2004 16:04:45 -0000	1.31
+++ compiler/gcc.m	22 Mar 2005 12:08:05 -0000
@@ -65,7 +65,8 @@
 :- module gcc.
 :- interface.
 
-:- import_module io, bool.
+:- import_module bool.
+:- import_module io.
 
 %-----------------------------------------------------------------------------%
 
@@ -674,7 +675,8 @@
 
 :- implementation.
 
-:- import_module int, string.
+:- import_module int.
+:- import_module string.
 
 :- pragma foreign_decl("C", "
 
Index: compiler/global_data.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/global_data.m,v
retrieving revision 1.7
diff -u -b -r1.7 global_data.m
--- compiler/global_data.m	19 Jan 2005 03:10:33 -0000	1.7
+++ compiler/global_data.m	22 Mar 2005 12:08:32 -0000
@@ -20,7 +20,8 @@
 :- import_module ll_backend__llds.
 :- import_module mdbcomp__prim_data. % for module_name
 
-:- import_module bool, list.
+:- import_module bool.
+:- import_module list.
 
 :- type global_data.
 
@@ -59,7 +60,9 @@
 :- pred global_data_set_static_cell_info(static_cell_info::in,
 	global_data::in, global_data::out) is det.
 
-:- import_module bool, list, assoc_list.
+:- import_module assoc_list.
+:- import_module bool.
+:- import_module list.
 
 :- type static_cell_info.
 
@@ -90,7 +93,12 @@
 :- import_module ll_backend__layout.
 :- import_module ll_backend__llds_out.
 
-:- import_module int, counter, set, map, std_util, require.
+:- import_module counter.
+:- import_module int.
+:- import_module map.
+:- import_module require.
+:- import_module set.
+:- import_module std_util.
 
 :- type proc_var_map	==	map(pred_proc_id, comp_gen_c_var).
 :- type proc_layout_map	==	map(pred_proc_id, proc_layout_info).
Index: compiler/globals.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/globals.m,v
retrieving revision 1.65
diff -u -b -r1.65 globals.m
--- compiler/globals.m	24 Feb 2005 06:07:08 -0000	1.65
+++ compiler/globals.m	22 Mar 2005 12:08:53 -0000
@@ -22,7 +22,12 @@
 :- import_module mdbcomp.
 :- import_module mdbcomp__prim_data. % for module_name
 
-:- import_module bool, getopt_io, list, map, io, std_util.
+:- import_module bool.
+:- import_module getopt_io.
+:- import_module io.
+:- import_module list.
+:- import_module map.
+:- import_module std_util.
 
 :- type globals.
 
@@ -245,7 +250,10 @@
 
 :- implementation.
 
-:- import_module map, std_util, require, string.
+:- import_module map.
+:- import_module require.
+:- import_module std_util.
+:- import_module string.
 
 convert_target(String, Target) :-
 	convert_target_2(string__to_lower(String), Target).
Index: compiler/goal_form.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/goal_form.m,v
retrieving revision 1.11
diff -u -b -r1.11 goal_form.m
--- compiler/goal_form.m	16 Oct 2004 15:05:51 -0000	1.11
+++ compiler/goal_form.m	22 Mar 2005 12:09:04 -0000
@@ -120,7 +120,11 @@
 :- import_module parse_tree__prog_data.
 :- import_module transform_hlds__term_util.
 
-:- import_module bool, int, map, std_util, require.
+:- import_module bool.
+:- import_module int.
+:- import_module map.
+:- import_module require.
+:- import_module std_util.
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/goal_path.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/goal_path.m,v
retrieving revision 1.21
diff -u -b -r1.21 goal_path.m
--- compiler/goal_path.m	20 Dec 2004 01:15:37 -0000	1.21
+++ compiler/goal_path.m	22 Mar 2005 12:09:15 -0000
@@ -44,7 +44,12 @@
 :- import_module hlds__hlds_goal.
 :- import_module parse_tree__prog_data.
 
-:- import_module char, int, list, map, std_util, require.
+:- import_module char.
+:- import_module int.
+:- import_module list.
+:- import_module map.
+:- import_module require.
+:- import_module std_util.
 
 :- type slot_info
 	--->	slot_info(
Index: compiler/goal_store.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/goal_store.m,v
retrieving revision 1.4
diff -u -b -r1.4 goal_store.m
--- compiler/goal_store.m	15 Mar 2003 03:08:46 -0000	1.4
+++ compiler/goal_store.m	22 Mar 2005 12:12:38 -0000
@@ -23,7 +23,9 @@
 :- import_module hlds__hlds_pred.
 :- import_module hlds__instmap.
 
-:- import_module bool, set, std_util.
+:- import_module bool.
+:- import_module set.
+:- import_module std_util.
 
 %-----------------------------------------------------------------------------%
 
@@ -50,7 +52,10 @@
 
 :- import_module hlds__goal_util.
 
-:- import_module int, list, map, require.
+:- import_module int.
+:- import_module list.
+:- import_module map.
+:- import_module require.
 
 :- type goal_store(T) == map__map(T, goal).
 
@@ -95,7 +100,6 @@
 				ancestors_2(GoalStore, Ancestors `append` Ids,
 					set__insert(VisitedIds, Id),
 					VarTypes, ModuleInfo, FullyStrict)
-
 		).
 
 :- func direct_ancestors(goal_store(T), T, vartypes, module_info, bool)
@@ -117,7 +121,6 @@
 	not goal_util__can_reorder_goals(ModuleInfo, VarTypes, FullyStrict,
 			EarlierInstMap, EarlierGoal,
 			LaterInstMap, LaterGoal).
-
 
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
Index: compiler/goal_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/goal_util.m,v
retrieving revision 1.103
diff -u -b -r1.103 goal_util.m
--- compiler/goal_util.m	15 Feb 2005 05:22:16 -0000	1.103
+++ compiler/goal_util.m	22 Mar 2005 12:10:52 -0000
@@ -21,7 +21,12 @@
 :- import_module mdbcomp__prim_data.
 :- import_module parse_tree__prog_data.
 
-:- import_module assoc_list, bool, list, set, map, term.
+:- import_module assoc_list.
+:- import_module bool.
+:- import_module list.
+:- import_module map.
+:- import_module set.
+:- import_module term.
 
 	% create_renaming(OutputVars, InstMapDelta, !VarTypes, !VarSet,
 	%	UnifyGoals, NewVars, Renaming):
@@ -287,7 +292,11 @@
 :- import_module parse_tree__prog_mode.
 :- import_module parse_tree__prog_util.
 
-:- import_module int, string, require, varset, std_util.
+:- import_module int.
+:- import_module require.
+:- import_module std_util.
+:- import_module string.
+:- import_module varset.
 
 %-----------------------------------------------------------------------------%
 
@@ -1285,7 +1294,6 @@
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
 
-
 goal_util__can_reorder_goals(ModuleInfo, VarTypes, FullyStrict,
 		InstmapBeforeEarlierGoal, EarlierGoal, InstmapBeforeLaterGoal,
 		LaterGoal) :-
@@ -1317,7 +1325,6 @@
 	\+ goal_depends_on_earlier_goal(EarlierGoal, LaterGoal,
 		InstmapBeforeLaterGoal, VarTypes, ModuleInfo).
 
-
 goal_util__reordering_maintains_termination(ModuleInfo, FullyStrict, 
 		EarlierGoal, LaterGoal) :-
 	EarlierGoal = _ - EarlierGoalInfo,
Index: compiler/graph_colour.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/graph_colour.m,v
retrieving revision 1.12
diff -u -b -r1.12 graph_colour.m
--- compiler/graph_colour.m	5 Apr 2004 05:06:47 -0000	1.12
+++ compiler/graph_colour.m	22 Mar 2005 12:11:19 -0000
@@ -27,7 +27,8 @@
 
 :- implementation.
 
-:- import_module list, require.
+:- import_module list.
+:- import_module require.
 
 graph_colour__group_elements(Constraints, Colours) :-
 	set__power_union(Constraints, AllVars),
Index: compiler/handle_options.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.223
diff -u -b -r1.223 handle_options.m
--- compiler/handle_options.m	22 Mar 2005 06:39:57 -0000	1.223
+++ compiler/handle_options.m	22 Mar 2005 12:11:46 -0000
@@ -165,11 +165,13 @@
 	check_option_values(OptionTable0, OptionTable, Target, GC_Method,
 		TagsMethod, TermNorm, TraceLevel, TraceSuppress,
 		MaybeThreadSafe, [], CheckErrors),
-	( CheckErrors = [] ->
+	(
+		CheckErrors = [],
 		postprocess_options_2(OptionTable, Target, GC_Method,
 			TagsMethod, TermNorm, TraceLevel, TraceSuppress,
 			MaybeThreadSafe, [], Errors, !IO)
 	;
+		CheckErrors = [_ | _],
 		Errors = CheckErrors
 	).
 
Index: compiler/hlds_module.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_module.m,v
retrieving revision 1.111
diff -u -b -r1.111 hlds_module.m
--- compiler/hlds_module.m	22 Mar 2005 06:39:59 -0000	1.111
+++ compiler/hlds_module.m	22 Mar 2005 12:13:25 -0000
@@ -34,7 +34,12 @@
 :- import_module parse_tree__prog_data.
 :- import_module recompilation.
 
-:- import_module relation, map, std_util, list, set, multi_map.
+:- import_module list.
+:- import_module map.
+:- import_module multi_map.
+:- import_module relation.
+:- import_module set.
+:- import_module std_util.
 
 :- implementation.
 
Index: compiler/mark_static_terms.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mark_static_terms.m,v
retrieving revision 1.14
diff -u -b -r1.14 mark_static_terms.m
--- compiler/mark_static_terms.m	22 Mar 2005 06:40:07 -0000	1.14
+++ compiler/mark_static_terms.m	22 Mar 2005 12:13:46 -0000
@@ -44,7 +44,11 @@
 :- type static_info == map(prog_var, static_cons).
 
 :- import_module hlds__hlds_goal.
-:- import_module int, list, std_util, require.
+
+:- import_module int.
+:- import_module list.
+:- import_module require.
+:- import_module std_util.
 
 mark_static_terms(_ModuleInfo, !Proc) :-
 		% The ModuleInfo argument is there just for passes_aux
Index: compiler/mlds_to_il.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mlds_to_il.m,v
retrieving revision 1.147
diff -u -b -r1.147 mlds_to_il.m
--- compiler/mlds_to_il.m	23 Mar 2005 00:46:17 -0000	1.147
+++ compiler/mlds_to_il.m	23 Mar 2005 00:50:12 -0000
@@ -1005,7 +1005,7 @@
 
 		% Add a store after the alloc instrs (if necessary)
 	AllocInstrs = list__condense(tree__flatten(
-		tree__list([
+		tree_list([
 			context_node(Context),
 			comment_node(string__append("allocation for ",
 				FieldName)),
@@ -1014,7 +1014,7 @@
 
 		% Add a load before the init instrs (if necessary)
 	InitInstrs = list__condense(tree__flatten(
-		tree__list([
+		tree_list([
 			context_node(Context),
 			comment_node(string__append("initializer for ",
 				FieldName)),
@@ -1110,7 +1110,7 @@
 			(pred(_::in, Instr::out, Num::in, Num+1::out) is det :-
 				Instr = ldarg(index(Num))
 			), TypeParams, LoadInstrs, 0, _),
-		InstrsTree1 = tree__list([
+		InstrsTree1 = tree_list([
 			comment_node("external -- call handwritten version"),
 			node(LoadInstrs),
 			instr_node(call(get_static_methodref(ClassName,
@@ -1122,7 +1122,7 @@
 		% Retrieve the locals, put them in the enclosing
 		% scope.
 	il_info_get_locals_list(!.Info, Locals),
-	InstrsTree2 = tree__list([
+	InstrsTree2 = tree_list([
 		context_node(Context),
 		node(CtorInstrs),
 		context_node(Context),
@@ -1200,7 +1200,7 @@
 
 			% A code block to catch any exception at all.
 
-		CatchAnyException = tree__list([
+		CatchAnyException = tree_list([
 			instr_node(start_block(
 				catch(ExceptionClassName),
 				OuterCatchBlockId)),
@@ -1216,7 +1216,7 @@
 			]),
 
 			% Code to catch Mercury exceptions.
-		CatchUserException = tree__list([
+		CatchUserException = tree_list([
 			instr_node(start_block(
 				catch(MercuryExceptionClassName),
 				InnerCatchBlockId)),
@@ -1262,7 +1262,7 @@
 			%	System.Environment.ExitCode = 1;
 			% }
 
-		InstrsTree = tree__list([
+		InstrsTree = tree_list([
 
 					% outer try block
 				instr_node(start_block(try, OuterTryBlockId)),
@@ -1470,7 +1470,7 @@
 				AllocInstrs, InitInstrs, !Info),
 			string__append("initializer for ", NameString,
 				Comment),
-			!:Tree = tree__list([
+			!:Tree = tree_list([
 				!.Tree,
 				context_node(Context),
 				comment_node(Comment),
@@ -1632,7 +1632,7 @@
 	list__map((pred((K - V)::in, (K - W)::out) is det :-
 		W = mlds_type_to_ilds_type(DataRep, V)), Locals, ILLocals),
 	Scope = scope(ILLocals),
-	Instrs = tree__list([
+	Instrs = tree_list([
 			context_node(Context),
 			instr_node(start_block(Scope, BlockId)),
 			InitInstrsTree,
@@ -1713,7 +1713,7 @@
 			LoadMemRefInstrs, ReturnsStoredInstrs, !Info)
 	),
 	list__map_foldl(load, Args, ArgsLoadInstrsTrees, !Info),
-	ArgsLoadInstrs = tree__list(ArgsLoadInstrsTrees),
+	ArgsLoadInstrs = tree_list(ArgsLoadInstrsTrees),
 	( Function = const(Const) ->
 		FunctionLoadInstrs = empty,
 		const_rval_to_function(Const, MemberName),
@@ -1728,7 +1728,7 @@
 		Instrs0 = [calli(signature(call_conv(no, default),
 			ReturnParam, ParamsList))]
 	),
-	Instrs = tree__list([
+	Instrs = tree_list([
 		context_node(Context),
 		comment_node("call"),
 		LoadMemRefInstrs,
@@ -1746,7 +1746,7 @@
 	il_info_make_next_label(DoneLabel, !Info),
 	statement_to_il(ThenCase, ThenInstrs, !Info),
 	maybe_map_fold(statement_to_il, ElseCase, empty, ElseInstrs, !Info),
-	Instrs = tree__list([
+	Instrs = tree_list([
 		context_node(Context),
 		comment_node("if then else"),
 		ConditionInstrs,
@@ -1774,7 +1774,7 @@
 	statement_to_il(Body, BodyInstrs, !Info),
 	(
 		AtLeastOnce = no,
-		Instrs = tree__list([
+		Instrs = tree_list([
 			context_node(Context),
 			comment_node("while"),
 			instr_node(label(StartLabel)),
@@ -1787,7 +1787,7 @@
 		AtLeastOnce = yes,
 			% XXX this generates a branch over branch which
 			% is suboptimal.
-		Instrs = tree__list([
+		Instrs = tree_list([
 			context_node(Context),
 			comment_node("while (actually do ... while)"),
 			instr_node(label(StartLabel)),
@@ -1802,7 +1802,7 @@
 	(
 		Rvals = [Rval],
 		load(Rval, LoadInstrs, !Info),
-		Instrs = tree__list([
+		Instrs = tree_list([
 			context_node(Context),
 			LoadInstrs,
 			instr_node(ret)])
@@ -1854,7 +1854,7 @@
 	%
 
 	NewObjInstr = newobj_constructor(il_commit_class_name, []),
-	Instrs = tree__list([
+	Instrs = tree_list([
 			context_node(Context),
 			comment_node("do_commit/1"),
 			instr_node(NewObjInstr),
@@ -1887,7 +1887,7 @@
 	il_info_make_next_label(DoneLabel, !Info),
 
 	ClassName = il_commit_class_name,
-	Instrs = tree__list([
+	Instrs = tree_list([
 		context_node(Context),
 		comment_node("try_commit/3"),
 
@@ -1909,7 +1909,7 @@
 		Instrs, !Info) :-
 	load(Rval, RvalLoadInstrs, !Info),
 	Targets = list__map(func(L) = label_target(L), MLDSLabels),
-	Instrs = tree__list([
+	Instrs = tree_list([
 		context_node(Context),
 		comment_node("computed goto"),
 		RvalLoadInstrs,
@@ -1972,7 +1972,7 @@
 			Num::in, Num + 1::out) is det :-
 				Instr = ldarg(index(Num))),
 			TypeParams, LoadArgInstrs, 0, _),
-		Instrs = tree__list([
+		Instrs = tree_list([
 			comment_node(
 				"outline foreign proc -- " ++
 				"call handwritten version"),
@@ -2014,7 +2014,7 @@
 	load(Rval, LoadRvalInstrs, !Info),
 	get_load_store_lval_instrs(Lval, LoadMemRefInstrs, StoreLvalInstrs,
 		!Info),
-	Instrs = tree__list([
+	Instrs = tree_list([
 		comment_node("assign"),
 		LoadMemRefInstrs,
 		LoadRvalInstrs,
@@ -2034,7 +2034,7 @@
 		% lval, which hopefully gives the garbage collector a good
 		% solid hint that this storage is no longer required.
 	get_load_store_lval_instrs(Target, LoadInstrs, StoreInstrs, !Info),
-	Instrs = tree__list([LoadInstrs, instr_node(ldnull), StoreInstrs]).
+	Instrs = tree_list([LoadInstrs, instr_node(ldnull), StoreInstrs]).
 
 atomic_statement_to_il(new_object(Target, _MaybeTag, HasSecTag, Type, Size,
 		MaybeCtorName, Args0, ArgTypes0), Instrs, !Info) :-
@@ -2094,11 +2094,11 @@
 		ILArgTypes = list__map(mlds_type_to_ilds_type(DataRep),
 			ArgTypes),
 		list__map_foldl(load, Args, ArgsLoadInstrsTrees, !Info),
-		ArgsLoadInstrs = tree__list(ArgsLoadInstrsTrees),
+		ArgsLoadInstrs = tree_list(ArgsLoadInstrsTrees),
 		get_load_store_lval_instrs(Target, LoadMemRefInstrs,
 			StoreLvalInstrs, !Info),
 		CallCtor = newobj_constructor(ClassName, ILArgTypes),
-		Instrs = tree__list([
+		Instrs = tree_list([
 			LoadMemRefInstrs,
 			comment_node("new object (call constructor)"),
 			ArgsLoadInstrs,
@@ -2157,12 +2157,12 @@
 
 			load(NewRval, I2, S1, S),
 			I3 = instr_node(stelem(il_generic_simple_type)),
-			I = tree__list([I0, I1, I2, I3]),
+			I = tree_list([I0, I1, I2, I3]),
 			Arg = (Index + 1) - S
 		),
 		list__map_foldl(LoadInArray, Args0, ArgsLoadInstrsTrees,
 			0 - !.Info, _ - !:Info),
-		ArgsLoadInstrs = tree__list(ArgsLoadInstrsTrees),
+		ArgsLoadInstrs = tree_list(ArgsLoadInstrsTrees),
 
 			% Get the instructions to load and store the
 			% target.
@@ -2180,7 +2180,7 @@
 		),
 		load(SizeInWordsRval, LoadSizeInstrs, !Info),
 
-		Instrs = tree__list([
+		Instrs = tree_list([
 			LoadMemRefInstrs,
 			comment_node("new object"),
 			LoadSizeInstrs,
@@ -2197,7 +2197,7 @@
 	(
 		T = user_target_code(Code, MaybeContext, Attrs),
 		( yes(max_stack_size(N)) = get_max_stack_attribute(Attrs) ->
-			Instrs = tree__list([
+			Instrs = tree_list([
 				( MaybeContext = yes(Context) ->
 					context_node(mlds__make_context(
 						Context))
@@ -2273,7 +2273,7 @@
 					DataRep, FieldType),
 				load(FieldRval, LoadArrayRval, !Info),
 				load(OffsetRval, LoadIndexRval, !Info),
-				LoadMemRefInstrs = tree__list([
+				LoadMemRefInstrs = tree_list([
 					LoadArrayRval, LoadIndexRval]),
 				StoreLvalInstrs = node([stelem(FieldILType)])
 			; FieldNum = named_field(_, _),
@@ -2284,7 +2284,7 @@
 			get_fieldref(DataRep, FieldNum, FieldType, ClassType,
 				FieldRef, CastClassInstrs),
 			load(FieldRval, LoadMemRefInstrs0, !Info),
-			LoadMemRefInstrs = tree__list([
+			LoadMemRefInstrs = tree_list([
 				LoadMemRefInstrs0,
 				CastClassInstrs]),
 			StoreLvalInstrs = instr_node(stfld(FieldRef))
@@ -2337,7 +2337,7 @@
 			LoadInstruction = ldfld(FieldRef),
 			OffSetLoadInstrs = empty
 		),
-		Instrs = tree__list([
+		Instrs = tree_list([
 			RvalLoadInstrs,
 			CastClassInstrs,
 			OffSetLoadInstrs,
@@ -2346,7 +2346,7 @@
 	; Lval = mem_ref(Rval, MLDS_Type),
 		SimpleType = mlds_type_to_ilds_simple_type(DataRep, MLDS_Type),
 		load(Rval, RvalLoadInstrs, !Info),
-		Instrs = tree__list([
+		Instrs = tree_list([
 			RvalLoadInstrs,
 			instr_node(ldind(SimpleType))
 			])
@@ -2396,13 +2396,13 @@
 load(unop(Unop, Rval), Instrs, !Info) :-
 	load(Rval, RvalLoadInstrs, !Info),
 	unaryop_to_il(Unop, Rval, UnOpInstrs, !Info),
-	Instrs = tree__list([RvalLoadInstrs, UnOpInstrs]).
+	Instrs = tree_list([RvalLoadInstrs, UnOpInstrs]).
 
 load(binop(BinOp, R1, R2), Instrs, !Info) :-
 	load(R1, R1LoadInstrs, !Info),
 	load(R2, R2LoadInstrs, !Info),
 	binaryop_to_il(BinOp, BinaryOpInstrs, !Info),
-	Instrs = tree__list([R1LoadInstrs, R2LoadInstrs, BinaryOpInstrs]).
+	Instrs = tree_list([R1LoadInstrs, R2LoadInstrs, BinaryOpInstrs]).
 
 load(mem_addr(Lval), Instrs, !Info) :-
 	DataRep = !.Info ^ il_data_rep,
@@ -2422,7 +2422,7 @@
 		get_fieldref(DataRep, FieldNum, FieldType, ClassType,
 			FieldRef, CastClassInstrs),
 		load(Rval, RvalLoadInstrs, !Info),
-		Instrs = tree__list([
+		Instrs = tree_list([
 			RvalLoadInstrs,
 			CastClassInstrs,
 			instr_node(ldflda(FieldRef))
@@ -2432,7 +2432,7 @@
 		Instrs = throw_unimplemented("load mem_addr lval mem_ref")
 	).
 
-load(self(_), tree__list([instr_node(ldarg(index(0)))]), !Info).
+load(self(_), tree_list([instr_node(ldarg(index(0)))]), !Info).
 
 :- pred store(mlds__lval::in, instr_tree::out, il_info::in, il_info::out)
 	is det.
@@ -2442,7 +2442,7 @@
 	get_fieldref(DataRep, FieldNum, FieldType, ClassType,
 		FieldRef, CastClassInstrs),
 	load(Rval, RvalLoadInstrs, !Info),
-	Instrs = tree__list([
+	Instrs = tree_list([
 		CastClassInstrs,
 		RvalLoadInstrs,
 		instr_node(stfld(FieldRef))]).
@@ -2578,7 +2578,7 @@
 		;
 			% convert an unboxed type to a boxed type:
 			% box it first, then cast
-			Instrs = tree__list([
+			Instrs = tree_list([
 				convert_to_object(SrcILType),
 				instr_node(castclass(DestILType))
 			])
@@ -2599,7 +2599,7 @@
 				% generate MLDS so we don't need to do this
 				% XXX This looks wrong for --high-level-data.
 				% -fjh.
-				Instrs = tree__list([
+				Instrs = tree_list([
 					comment_node(
 						"loading out of an MR_Word"),
 					instr_node(ldc(int32, i(0))),
@@ -2612,7 +2612,7 @@
 			;
 				% XXX It would be nicer if the MLDS used an
 				% unbox to do this.
-				Instrs = tree__list([
+				Instrs = tree_list([
 					comment_node(
 					"turning a cast into an unbox"),
 					convert_from_object(DestILType)
@@ -2620,7 +2620,7 @@
 			)
 		;
 			DestILType = ilds__type(_, DestSimpleType),
-			Instrs = tree__list([
+			Instrs = tree_list([
 				comment_node("cast between value types"),
 				instr_node(conv(DestSimpleType))
 			])
@@ -2824,18 +2824,18 @@
 		load(Operand2, Op2Instr, !Info),
 		OpInstr = instr_node(
 			bne(unsigned, label_target(ElseLabel))),
-		Instrs = tree__list([Op1Instr, Op2Instr, OpInstr])
+		Instrs = tree_list([Op1Instr, Op2Instr, OpInstr])
 	;
 		Rval = binop(ne, Operand1, Operand2)
 	->
 		load(Operand1, Op1Instr, !Info),
 		load(Operand2, Op2Instr, !Info),
 		OpInstr = instr_node(beq(label_target(ElseLabel))),
-		Instrs = tree__list([Op1Instr, Op2Instr, OpInstr])
+		Instrs = tree_list([Op1Instr, Op2Instr, OpInstr])
 	;
 		load(Rval, RvalLoadInstrs, !Info),
 		ExtraInstrs = instr_node(brfalse(label_target(ElseLabel))),
-		Instrs = tree__list([RvalLoadInstrs, ExtraInstrs])
+		Instrs = tree_list([RvalLoadInstrs, ExtraInstrs])
 	).
 
 %-----------------------------------------------------------------------------%
Index: compiler/mode_robdd.check.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mode_robdd.check.m,v
retrieving revision 1.3
diff -u -b -r1.3 mode_robdd.check.m
--- compiler/mode_robdd.check.m	22 Mar 2005 06:40:13 -0000	1.3
+++ compiler/mode_robdd.check.m	22 Mar 2005 12:14:10 -0000
@@ -171,7 +171,8 @@
 :- import_module sparse_bitset.
 
 % Uncomment these for debugging.
-% :- import_module io, pprint.
+% :- import_module io
+% :- import_module pprint.
 % :- import_module unsafe.
 
 % The two fields of this type represent the two mode_robdd implementations
Index: compiler/module_qual.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/module_qual.m,v
retrieving revision 1.98
diff -u -b -r1.98 module_qual.m
--- compiler/module_qual.m	20 Mar 2005 02:24:35 -0000	1.98
+++ compiler/module_qual.m	22 Mar 2005 12:14:34 -0000
@@ -23,7 +23,10 @@
 :- import_module parse_tree.prog_data.
 :- import_module recompilation.
 
-:- import_module bool, list, std_util, io.
+:- import_module bool.
+:- import_module io.
+:- import_module list.
+:- import_module std_util.
 
 	% module_qualify_items(Items0, Items, ModuleName, ReportUndefErrors,
 	%	MQ_Info, NumErrors, UndefTypes, UndefModes):
@@ -114,8 +117,14 @@
 :- import_module parse_tree.prog_util.
 :- import_module parse_tree.prog_type.
 
-:- import_module int, map, require, set, string, term, varset.
 :- import_module assoc_list.
+:- import_module int.
+:- import_module map.
+:- import_module require.
+:- import_module set.
+:- import_module string.
+:- import_module term.
+:- import_module varset.
 
 module_qual.module_qualify_items(Items0, Items, ModuleName, ReportErrors,
 		Info, NumErrors, UndefTypes, UndefModes, !IO) :-
Index: compiler/recompilation.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/recompilation.m,v
retrieving revision 1.12
diff -u -b -r1.12 recompilation.m
--- compiler/recompilation.m	22 Mar 2005 06:40:21 -0000	1.12
+++ compiler/recompilation.m	22 Mar 2005 12:15:20 -0000
@@ -251,7 +251,12 @@
 :- import_module parse_tree__modules.
 :- import_module parse_tree__prog_util.
 
-:- import_module int, time, bool, list, require, string.
+:- import_module bool.
+:- import_module int.
+:- import_module list.
+:- import_module require.
+:- import_module string.
+:- import_module time.
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/rl_exprn.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rl_exprn.m,v
retrieving revision 1.49
diff -u -b -r1.49 rl_exprn.m
--- compiler/rl_exprn.m	21 Mar 2005 04:45:50 -0000	1.49
+++ compiler/rl_exprn.m	22 Mar 2005 12:15:56 -0000
@@ -135,32 +135,42 @@
 :- import_module aditi_backend__rl_out.
 :- import_module backend_libs.
 :- import_module backend_libs__builtin_ops.
+:- import_module backend_libs__name_mangle.
 :- import_module backend_libs__rtti.
 :- import_module check_hlds__inst_match.
 :- import_module check_hlds__mode_util.
 :- import_module check_hlds__type_util.
-:- import_module parse_tree__error_util.
+:- import_module hlds__goal_util.
 :- import_module hlds__hlds_data.
 :- import_module hlds__hlds_error_util.
 :- import_module hlds__hlds_goal.
-:- import_module hlds__goal_util.
 :- import_module hlds__hlds_pred.
 :- import_module hlds__instmap.
 :- import_module hlds__special_pred.
-:- import_module libs__tree.
 :- import_module libs__globals.
 :- import_module libs__options.
+:- import_module libs__tree.
+:- import_module mdbcomp__prim_data.
 :- import_module mdbcomp__prim_data.
+:- import_module parse_tree__error_util.
 :- import_module parse_tree__prog_foreign.
 :- import_module parse_tree__prog_out.
-:- import_module parse_tree__prog_util.
 :- import_module parse_tree__prog_type.
+:- import_module parse_tree__prog_util.
 :- import_module transform_hlds__inlining.
-:- import_module backend_libs__name_mangle.
-:- import_module mdbcomp__prim_data.
 
-:- import_module assoc_list, bool, char, counter, int, map.
-:- import_module require, set, std_util, string, term, varset.
+:- import_module assoc_list.
+:- import_module bool.
+:- import_module char.
+:- import_module counter.
+:- import_module int.
+:- import_module map.
+:- import_module require.
+:- import_module set.
+:- import_module std_util.
+:- import_module string.
+:- import_module term.
+:- import_module varset.
 
 	% A compare expression tests each attribute in a list of attributes
 	% in turn.
@@ -2710,31 +2720,24 @@
 :- pred rl_exprn__get_exprn_labels(int::in, int::out, map(label_id, int)::in,
 		map(label_id, int)::out, byte_tree::in, byte_tree::out) is det.
 
-rl_exprn__get_exprn_labels(PC0, PC0, Labels, Labels, empty, empty).
-rl_exprn__get_exprn_labels(PC0, PC, Labels0, Labels,
-		tree(CodeA0, CodeB0), tree(CodeA, CodeB)) :-
-	rl_exprn__get_exprn_labels(PC0, PC1, Labels0, Labels1, CodeA0, CodeA),
-	rl_exprn__get_exprn_labels(PC1, PC, Labels1, Labels, CodeB0, CodeB).
-rl_exprn__get_exprn_labels(PC0, PC, Labels0, Labels,
-		node(Instrs0), node(Instrs)) :-
-	rl_exprn__get_exprn_labels_list(PC0, PC,
-		Labels0, Labels, Instrs0, Instrs).
-
-:- pred rl_exprn__get_exprn_labels_list(int::in, int::out,
-		map(label_id, int)::in, map(label_id, int)::out,
-		list(bytecode)::in, list(bytecode)::out) is det.
-
-rl_exprn__get_exprn_labels_list(PC, PC, Labels, Labels, [], []).
-rl_exprn__get_exprn_labels_list(PC0, PC, Labels0, Labels,
-		[Instr | Instrs0], Instrs) :-
+rl_exprn__get_exprn_labels(!PC, !Labels, !Code) :-
+	tree.map_foldl2(rl_exprn__get_exprn_labels_list, !Code, !PC, !Labels).
+
+:- pred rl_exprn__get_exprn_labels_list(
+	list(bytecode)::in, list(bytecode)::out, int::in, int::out,
+	map(label_id, int)::in, map(label_id, int)::out) is det.
+
+rl_exprn__get_exprn_labels_list([], [], PC, PC, Labels, Labels).
+rl_exprn__get_exprn_labels_list([Instr | Instrs0], Instrs,
+		PC0, PC, Labels0, Labels) :-
 	( Instr = rl_PROC_label(_) ->
 		PC1 = PC0
 	;
 		functor(Instr, _, Arity),
 		PC1 = PC0 + Arity + 1		% +1 for the opcode
 	),
-	rl_exprn__get_exprn_labels_list(PC1, PC, Labels0, Labels1,
-		Instrs0, Instrs1),
+	rl_exprn__get_exprn_labels_list(Instrs0, Instrs1,
+		PC1, PC, Labels0, Labels1),
 	( Instr = rl_PROC_label(Label) ->
 		% Register the label and remove the instruction.
 		map__det_insert(Labels1, Label, PC0, Labels),
Index: compiler/rl_file.pp
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rl_file.pp,v
retrieving revision 1.9
diff -u -b -r1.9 rl_file.pp
--- compiler/rl_file.pp	7 Feb 2005 11:41:05 -0000	1.9
+++ compiler/rl_file.pp	24 Mar 2005 01:36:26 -0000
@@ -26,7 +26,9 @@
 
 #if INCLUDE_ADITI_OUTPUT	% See ../Mmake.common.in.
 :- import_module aditi_backend__rl_code.
-:- import_module assoc_list, list.
+
+:- import_module assoc_list.
+:- import_module list.
 
 	% Write a text representation of an RL file to the current
 	% text stream output.
@@ -118,7 +120,11 @@
 %-----------------------------------------------------------------------------%
 :- implementation.
 
-:- import_module char, int, require, string, std_util.
+:- import_module char.
+:- import_module int.
+:- import_module require.
+:- import_module std_util.
+:- import_module string.
 
 :- type rl_state == pair(int, io__state).
 
@@ -434,7 +440,7 @@
 %-----------------------------------------------------------------------------%
 
 :- pred rl_file__write_proc(constant_pool::in, procedure::in, 
-		io__state::di, io__state::uo) is det.
+	io::di, io::uo) is det.
 
 rl_file__write_proc(Consts, Proc) -->
 	{ Proc = procedure(User, Module, Name, Schema, NArgs, 
@@ -475,7 +481,7 @@
 	io__write_string("\n\t]\n)").
 
 :- pred rl_file__write_instruction(bytecode::in,
-		io__state::di, io__state::uo) is det.
+	io::di, io::uo) is det.
 
 rl_file__write_instruction(Bytecode) -->
 	(
@@ -509,7 +515,7 @@
 %-----------------------------------------------------------------------------%
 
 :- pred rl_file__write_exprn(expression::in, int::in, int::out,
-		io__state::di, io__state::uo) is det.
+	io::di, io::uo) is det.
 
 rl_file__write_exprn(Exprn, ExprnNum0, ExprnNum) -->
 	{ ExprnNum = ExprnNum0 + 1 },
@@ -517,7 +523,7 @@
 	rl_file__write_exprn_2(Exprn, ExprnNum0).
 
 :- pred rl_file__write_exprn_2(expression::in, int::in,
-		io__state::di, io__state::uo) is det.
+	io::di, io::uo) is det.
 
 rl_file__write_exprn_2(Exprn, ExprnNum) -->
 	{ Exprn = expression(OutputSchema, OutputSchema2, VarSchema,
Index: compiler/rl_out.pp
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rl_out.pp,v
retrieving revision 1.27
diff -u -b -r1.27 rl_out.pp
--- compiler/rl_out.pp	1 Feb 2005 07:11:38 -0000	1.27
+++ compiler/rl_out.pp	24 Mar 2005 01:36:26 -0000
@@ -30,7 +30,9 @@
 #else
 #endif
 
-:- import_module list, io, std_util.
+:- import_module io.
+:- import_module list.
+:- import_module std_util.
 
 	% Output schemas for locally defined base and derived relations to
 	% <module>.base_schema and <module>.derived_schema respectively.
@@ -74,20 +76,30 @@
 :- import_module libs__globals.
 :- import_module libs__options.
 :- import_module libs__tree.
+:- import_module libs__tree.
+:- import_module mdbcomp__prim_data.
 :- import_module parse_tree__modules.
 :- import_module parse_tree__prog_data.
 :- import_module parse_tree__prog_out.
 :- import_module parse_tree__prog_util.
-:- import_module mdbcomp__prim_data.
 
 #if INCLUDE_ADITI_OUTPUT	% See ../Mmake.common.in.
 :- import_module aditi_backend__rl_exprn.
 #else
 #endif
 
+:- import_module assoc_list.
+:- import_module bool.
+:- import_module char.
 :- import_module getopt_io.
-:- import_module assoc_list, bool, char, int, map, multi_map, require, set.
-:- import_module string, term, libs__tree, varset.
+:- import_module int.
+:- import_module map.
+:- import_module multi_map.
+:- import_module require.
+:- import_module set.
+:- import_module string.
+:- import_module term.
+:- import_module varset.
 
 %-----------------------------------------------------------------------------%
 
@@ -2166,30 +2178,38 @@
 		K = K0
 	).
 
-rl_out__resolve_addresses(_, empty, empty).
-rl_out__resolve_addresses(ResolveAddr, node(InstrList0), node(InstrList)) :-
-	list__map(ResolveAddr, InstrList0, InstrList).
-rl_out__resolve_addresses(ResolveAddr, tree(CodeA0, CodeB0), 
-		tree(CodeA, CodeB)) :-
-	rl_out__resolve_addresses(ResolveAddr, CodeA0, CodeA),
-	rl_out__resolve_addresses(ResolveAddr, CodeB0, CodeB).
+rl_out__resolve_addresses(ResolveAddr, !Code) :-
+		% We can't call list.map directly because it has more than one
+		% mode, and so can't take its address.
+        tree.map(rl_out__resolve_addresses_2(ResolveAddr), !Code).
+
+:- pred rl_out__resolve_addresses_2(
+	pred(bytecode, bytecode)::in(pred(in, out) is det),
+	list(bytecode)::in, list(bytecode)::out) is det. 
+
+rl_out__resolve_addresses_2(ResolveAddr, !Code) :-
+        list.map(ResolveAddr, !Code).
 
 %-----------------------------------------------------------------------------%
 
 :- pred rl_out__instr_code_size(byte_tree::in, int::out) is det.
 
-rl_out__instr_code_size(empty, 0).
-rl_out__instr_code_size(node(Instrs), Size) :-
-	AddSize = (pred(Instr::in, S0::in, S::out) is det :-
+rl_out__instr_code_size(Code, Size) :-
+	tree.foldl(rl_out__accumulate_instrs_code_size, Code, 0, Size).
+
+:- pred rl_out__accumulate_instrs_code_size(list(bytecode)::in,
+	int::in, int::out) is det.
+
+rl_out__accumulate_instrs_code_size(Instrs, !Size) :-
+	list__foldl(rl_out__accumulate_instr_code_size, Instrs, !Size).
+
+:- pred rl_out__accumulate_instr_code_size(bytecode::in,
+	int::in, int::out) is det.
+
+rl_out__accumulate_instr_code_size(Instr, !Size) :-
 			bytecode_to_intlist(Instr, IntList),
-			list__length(IntList, S1),
-			S = S0 + S1
-		),
-	list__foldl(AddSize, Instrs, 0, Size).
-rl_out__instr_code_size(tree(CodeA, CodeB), Size) :-
-	rl_out__instr_code_size(CodeA, SizeA),
-	rl_out__instr_code_size(CodeB, SizeB),
-	Size = SizeA + SizeB.
+	list__length(IntList, NewSize),
+	!:Size= !.Size + NewSize.
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/term_errors.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/term_errors.m,v
retrieving revision 1.28
diff -u -b -r1.28 term_errors.m
--- compiler/term_errors.m	22 Mar 2005 06:40:27 -0000	1.28
+++ compiler/term_errors.m	22 Mar 2005 11:25:31 -0000
@@ -149,11 +149,16 @@
 :- import_module parse_tree__error_util.
 :- import_module parse_tree__mercury_to_mercury.
 :- import_module parse_tree__prog_out.
-:- import_module term.
 :- import_module transform_hlds__term_util.
-:- import_module varset.
 
-:- import_module bool, int, string, map, bag, require.
+:- import_module bag.
+:- import_module bool.
+:- import_module int.
+:- import_module map.
+:- import_module require.
+:- import_module string.
+:- import_module term.
+:- import_module varset.
 
 indirect_error(horder_call).
 indirect_error(pragma_foreign_code).
Index: compiler/term_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/term_util.m,v
retrieving revision 1.39
diff -u -b -r1.39 term_util.m
--- compiler/term_util.m	22 Mar 2005 06:40:28 -0000	1.39
+++ compiler/term_util.m	22 Mar 2005 11:25:09 -0000
@@ -163,7 +163,9 @@
 :- import_module parse_tree__prog_out.
 :- import_module parse_tree__prog_type.
 
-:- import_module assoc_list, require, string.
+:- import_module assoc_list.
+:- import_module require.
+:- import_module string.
 
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
Index: compiler/tree.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/tree.m,v
retrieving revision 1.17
diff -u -b -r1.17 tree.m
--- compiler/tree.m	23 Mar 2004 10:52:14 -0000	1.17
+++ compiler/tree.m	19 Mar 2005 05:15:50 -0000
@@ -4,7 +4,7 @@
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
 %
-% Main authors: conway, fjh.
+% Main authors: conway, fjh, zs.
 %
 % This file provides a 'tree' data type.
 % The code generater uses this to build a tree of instructions and
@@ -13,74 +13,175 @@
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
 
-:- module libs__tree.
+:- module libs.tree.
 
 %-----------------------------------------------------------------------------%
 
 :- interface.
 
+:- import_module bool.
 :- import_module list.
 
 :- type tree(T)
 	--->	empty
 	;	node(T)
-	;	tree(tree(T), tree(T)).
+	;	tree(tree(T), tree(T))
+	;	tree_list(list(tree(T))).
 
-:- func tree__flatten(tree(T)) =  list(T).
+:- func tree.flatten(tree(T)) =  list(T).
+:- pred tree.flatten(tree(T)::in, list(T)::out) is det.
 
-	% Make a tree from a list of trees.
-:- func tree__list(list(tree(T))) = tree(T).
+:- func tree.is_empty(tree(T)) = bool.
+:- pred tree.is_empty(tree(T)::in) is semidet.
 
-:- pred tree__flatten(tree(T)::in, list(T)::out) is det.
+:- func tree.tree_of_lists_is_empty(tree(list(T))) = bool.
+:- pred tree.tree_of_lists_is_empty(tree(list(T))::in) is semidet.
 
-:- pred tree__is_empty(tree(T)::in) is semidet.
+:- pred tree.foldl(pred(T, A, A)::in(pred(in, in, out) is det), tree(T)::in,
+	A::in, A::out) is det.
 
-:- pred tree__tree_of_lists_is_empty(tree(list(T))::in) is semidet.
+:- func tree.map(func(T) = U, tree(T)) = tree(U).
+:- pred tree.map(pred(T, U)::in(pred(in, out) is det),
+	tree(T)::in, tree(U)::out) is det.
 
-:- func tree__map(func(T) = U, tree(T)) = tree(U).
+:- pred tree.map_foldl(pred(T, U, A, A)::in(pred(in, out, in, out) is det),
+	tree(T)::in, tree(U)::out, A::in, A::out) is det.
 
-%-----------------------------------------------------------------------------%
-
-:- implementation.
-
-tree__flatten(T) = L :-
-	tree__flatten(T, L).
-
-tree__list([]) = empty.
-tree__list([X | Xs]) = tree(X, tree__list(Xs)).
-
-tree__flatten(T, L) :-
-	tree__flatten_2(T, [], L).
-
-	% flatten_2(T, L0, L) is true iff L is the list that results from
-	% traversing T left-to-right depth-first, and then appending L0.
-:- pred tree__flatten_2(tree(T)::in, list(T)::in, list(T)::out) is det.
-
-tree__flatten_2(empty, L, L).
-tree__flatten_2(node(T), L, [T|L]).
-tree__flatten_2(tree(T1,T2), L0, L) :-
-	tree__flatten_2(T2, L0, L1),
-	tree__flatten_2(T1, L1, L).
+:- pred tree.map_foldl2(
+	pred(T, U, A, A, B, B)::in(pred(in, out, in, out, in, out) is det),
+	tree(T)::in, tree(U)::out, A::in, A::out, B::in, B::out) is det.
 
 %-----------------------------------------------------------------------------%
 
-tree__is_empty(empty).
-tree__is_empty(tree(L, R)) :-
-	tree__is_empty(L),
-	tree__is_empty(R).
-
-%-----------------------------------------------------------------------------%
+:- implementation.
 
-tree__tree_of_lists_is_empty(empty).
-tree__tree_of_lists_is_empty(node([])).
-tree__tree_of_lists_is_empty(tree(L, R)) :-
-	tree__tree_of_lists_is_empty(L),
-	tree__tree_of_lists_is_empty(R).
+tree.flatten(T) = L :-
+	tree.flatten(T, L).
 
-%-----------------------------------------------------------------------------%
+tree.flatten(T, L) :-
+	tree.flatten_2(T, [], L).
 
-tree__map(_F, empty) = empty.
-tree__map(F, node(T)) = node(F(T)).
-tree__map(F, tree(L, R)) = tree(tree__map(F, L), tree__map(F, R)).
+	% flatten_2(T, !Flat) is true iff !:Flat is the list that results from
+	% traversing T left-to-right depth-first, and then appending !.Flat.
+:- pred tree.flatten_2(tree(T)::in, list(T)::in, list(T)::out) is det.
+
+tree.flatten_2(empty, !Flat).
+tree.flatten_2(node(Item), !Flat) :-
+	!:Flat = [Item | !.Flat].
+tree.flatten_2(tree(T1, T2), !Flat) :-
+	tree.flatten_2(T2, !Flat),
+	tree.flatten_2(T1, !Flat).
+tree.flatten_2(tree_list(List), !Flat) :-
+	tree.flatten_list(List, !Flat).
+
+	% flatten_list(List, !Flat) is true iff !:Flat is the list that results
+	% from traversing List left-to-right depth-first, and then appending
+	% !.Flat.
+:- pred tree.flatten_list(list(tree(T))::in, list(T)::in, list(T)::out)
+	is det.
+
+tree.flatten_list([], !Flat).
+tree.flatten_list([Head | Tail], !Flat) :-
+	tree.flatten_list(Tail, !Flat),
+	tree.flatten_2(Head, !Flat).
+
+%-----------------------------------------------------------------------------%
+
+tree.is_empty(T) :-
+	tree.is_empty(T) = yes.
+
+tree.is_empty(empty) = yes.
+tree.is_empty(node(_)) = no.
+tree.is_empty(tree(Left, Right)) =
+	( tree.is_empty(Left) = no ->
+		no
+	;
+		tree.is_empty(Right)
+	).
+tree.is_empty(tree_list(List)) = tree.list_is_empty(List).
+
+:- func tree.list_is_empty(list(tree(T))) = bool.
+
+tree.list_is_empty([]) = yes.
+tree.list_is_empty([Head | Tail]) =
+	( tree.is_empty(Head) = no ->
+		no
+	;
+		tree.list_is_empty(Tail)
+	).
+
+%-----------------------------------------------------------------------------%
+
+% Unfortunately, we can't factor out the common code between tree.is_empty
+% and tree.tree_of_lists_is_empty because their signatures are different,
+% and the signatures of their helpers must therefore be different too.
+
+tree.tree_of_lists_is_empty(T) :-
+	tree.tree_of_lists_is_empty(T) = yes.
+
+tree.tree_of_lists_is_empty(empty) = yes.
+tree.tree_of_lists_is_empty(node([])) = yes.
+tree.tree_of_lists_is_empty(node([_ | _])) = no.
+tree.tree_of_lists_is_empty(tree(Left, Right)) =
+	( tree.tree_of_lists_is_empty(Left) = no ->
+		no
+	;
+		tree.is_empty(Right)
+	).
+tree.tree_of_lists_is_empty(tree_list(List)) =
+	tree.list_tree_of_lists_is_empty(List).
+
+:- func tree.list_tree_of_lists_is_empty(list(tree(list(T)))) = bool.
+
+tree.list_tree_of_lists_is_empty([]) = yes.
+tree.list_tree_of_lists_is_empty([Head | Tail]) =
+	( tree.tree_of_lists_is_empty(Head) = no ->
+		no
+	;
+		tree.list_tree_of_lists_is_empty(Tail)
+	).
+
+%-----------------------------------------------------------------------------%
+
+tree.foldl(_P, empty, !A).
+tree.foldl(P, node(Node), !A) :-
+	P(Node, !A).
+tree.foldl(P, tree(Left, Right), !A) :-
+	tree.foldl(P, Left, !A),
+	tree.foldl(P, Right, !A).
+tree.foldl(P, tree_list(List), !A) :-
+	list.foldl(tree.foldl(P), List, !A).
+
+tree.map(_F, empty) = empty.
+tree.map(F, node(T)) = node(F(T)).
+tree.map(F, tree(L, R)) = tree(tree.map(F, L), tree.map(F, R)).
+tree.map(F, tree_list(L)) = tree_list(list.map(tree.map(F), L)).
+
+tree.map(_P, empty, empty).
+tree.map(P, node(Node0), node(Node)) :-
+	P(Node0, Node).
+tree.map(P, tree(Left0, Right0), tree(Left, Right)) :-
+	tree.map(P, Left0, Left),
+	tree.map(P, Right0, Right).
+tree.map(P, tree_list(List0), tree_list(List)) :-
+	list.map(tree.map(P), List0, List).
+
+tree.map_foldl(_P, empty, empty, !A).
+tree.map_foldl(P, node(Node0), node(Node), !A) :-
+	P(Node0, Node, !A).
+tree.map_foldl(P, tree(Left0, Right0), tree(Left, Right), !A) :-
+	tree.map_foldl(P, Left0, Left, !A),
+	tree.map_foldl(P, Right0, Right, !A).
+tree.map_foldl(P, tree_list(List0), tree_list(List), !A) :-
+	list.map_foldl(tree.map_foldl(P), List0, List, !A).
+
+tree.map_foldl2(_P, empty, empty, !A, !B).
+tree.map_foldl2(P, node(Node0), node(Node), !A, !B) :-
+	P(Node0, Node, !A, !B).
+tree.map_foldl2(P, tree(Left0, Right0), tree(Left, Right), !A, !B) :-
+	tree.map_foldl2(P, Left0, Left, !A, !B),
+	tree.map_foldl2(P, Right0, Right, !A, !B).
+tree.map_foldl2(P, tree_list(List0), tree_list(List), !A, !B) :-
+	list.map_foldl2(tree.map_foldl2(P), List0, List, !A, !B).
 
 %-----------------------------------------------------------------------------%
cvs diff: Diffing compiler/notes
Index: compiler/notes/overall_design.html
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/notes/overall_design.html,v
retrieving revision 1.4
diff -u -b -r1.4 overall_design.html
--- compiler/notes/overall_design.html	28 Jan 2005 07:11:47 -0000	1.4
+++ compiler/notes/overall_design.html	19 Mar 2005 04:09:53 -0000
@@ -52,6 +52,7 @@
 <li> mdbcomp: the library that defines the Mercury data structures generated
      by the compiler for the debugger
 <li> profiler: the Mercury profiler (written in Mercury)
+<li> deep_profiler: the Mercury deep profiler (written in Mercury)
 <li> analysis: an inter-module analysis framework (written in Mercury)
 <li> extras: additional Mercury libraries.  These are distributed
      separately from the main Mercury distribution.
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_glut
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing mdbcomp
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
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