[m-rev.] diff: more library cleanups (part 1)

Zoltan Somogyi zs at cs.mu.OZ.AU
Tue Mar 16 10:42:36 AEDT 2004


library/*.m:
	Bring these modules up to date with our current style guidelines.
	Use predmode declarations where appropriate. Use state variable syntax
	where appropriate. Reorder arguments where this makes it possible to
	to use state variable syntax. Standardize format of predicate
	description comments. Standardize indentation.

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
cvs diff: Diffing compiler/notes
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/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/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 java
cvs diff: Diffing java/library
cvs diff: Diffing java/runtime
cvs diff: Diffing library
Index: library/array.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/array.m,v
retrieving revision 1.129
diff -u -b -r1.129 array.m
--- library/array.m	9 Jan 2004 03:16:58 -0000	1.129
+++ library/array.m	9 Mar 2004 13:47:11 -0000
@@ -101,11 +101,9 @@
 
 	% array__make_empty_array(Array) creates an array of size zero
 	% starting at lower bound 0.
-:- pred array__make_empty_array(array(T)).
-:- mode array__make_empty_array(array_uo) is det.
+:- pred array__make_empty_array(array(T)::array_uo) is det.
 
-:- func array__make_empty_array = array(T).
-:- mode array__make_empty_array = array_uo is det.
+:- func array__make_empty_array = (array(T)::array_uo) is det.
 
 	% array__init(Size, Init, Array) creates an array
 	% with bounds from 0 to Size-1, with each element initialized to Init.
Index: library/assoc_list.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/assoc_list.m,v
retrieving revision 1.13
diff -u -b -r1.13 assoc_list.m
--- library/assoc_list.m	17 Jan 2001 04:34:41 -0000	1.13
+++ library/assoc_list.m	9 Mar 2004 13:25:30 -0000
@@ -28,53 +28,44 @@
 
 	% Swap the two sides of the pairs in each member of the list.
 
-:- pred assoc_list__reverse_members(assoc_list(K, V), assoc_list(V, K)).
-:- mode assoc_list__reverse_members(in, out) is det.
-
+:- pred assoc_list__reverse_members(assoc_list(K, V)::in,
+	assoc_list(V, K)::out) is det.
 :- func assoc_list__reverse_members(assoc_list(K, V)) = assoc_list(V, K).
 
 	% Zip together two lists; abort if they are of different lengths.
 
-:- pred assoc_list__from_corresponding_lists(list(K), list(V),
-						assoc_list(K,V)).
-:- mode assoc_list__from_corresponding_lists(in, in, out) is det.
-
+:- pred assoc_list__from_corresponding_lists(list(K)::in, list(V)::in,
+	assoc_list(K,V)::out) is det.
 :- func assoc_list__from_corresponding_lists(list(K), list(V))
 		= assoc_list(K,V).
 
 	% Return the first member of each pair.
 
-:- pred assoc_list__keys(assoc_list(K, V), list(K)).
-:- mode assoc_list__keys(in, out) is det.
-
+:- pred assoc_list__keys(assoc_list(K, V)::in, list(K)::out) is det.
 :- func assoc_list__keys(assoc_list(K, V)) = list(K).
 
 	% Return the second member of each pair.
 
-:- pred assoc_list__values(assoc_list(K, V), list(V)).
-:- mode assoc_list__values(in, out) is det.
-
+:- pred assoc_list__values(assoc_list(K, V)::in, list(V)::out) is det.
 :- func assoc_list__values(assoc_list(K, V)) = list(V).
 
 	% Return the two lists contain respectively the first and second member
 	% of each pair in the assoc_list.
 
-:- pred assoc_list__keys_and_values(assoc_list(K, V), list(K), list(V)).
-:- mode assoc_list__keys_and_values(in, out, out) is det.
+:- pred assoc_list__keys_and_values(assoc_list(K, V)::in,
+	list(K)::out, list(V)::out) is det.
 
 	% Find the first element of the association list that matches
 	% the given key, and return the associated value.
 
-:- pred assoc_list__search(assoc_list(K, V), K, V).
-:- mode assoc_list__search(in, in, out) is semidet.
+:- pred assoc_list__search(assoc_list(K, V)::in, K::in, V::out) is semidet.
 
 	% Find the first element of the association list that matches
 	% the given key. Return the associated value, and the original
 	% list with the selected element removed.
 
-:- pred assoc_list__remove(assoc_list(K, V), K, V,
-	assoc_list(K, V)).
-:- mode assoc_list__remove(in, in, out, out) is semidet.
+:- pred assoc_list__remove(assoc_list(K, V)::in, K::in, V::out,
+	assoc_list(K, V)::out) is semidet.
 
 :- func assoc_list__map_values(func(K, V) = W, assoc_list(K, V))
 	= assoc_list(K, W).
@@ -100,7 +91,8 @@
 		list__length(Vs, ValueLength),
 		string__int_to_string(ValueLength, ValueLengthString),
 		string__append_list(
-			["assoc_list__from_corresponding_lists: lists have different lengths.\n",
+			["assoc_list__from_corresponding_lists: " ++
+				"lists have different lengths.\n",
 			"\tKey list type: ",
 			KeyType,
 			"\n\tKey list length: ",
@@ -114,8 +106,8 @@
 		error(ErrorString)
 	).
 
-:- pred assoc_list__from_corresponding_2(list(K), list(V), assoc_list(K,V)).
-:- mode assoc_list__from_corresponding_2(in, in, out) is semidet.
+:- pred assoc_list__from_corresponding_2(list(K)::in, list(V)::in,
+	assoc_list(K,V)::out) is semidet.
 
 assoc_list__from_corresponding_2([], [], []).
 assoc_list__from_corresponding_2([A | As], [B | Bs], [A - B | ABs]) :-
Index: library/bag.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/bag.m,v
retrieving revision 1.22
diff -u -b -r1.22 bag.m
--- library/bag.m	26 May 2003 09:00:28 -0000	1.22
+++ library/bag.m	9 Mar 2004 13:32:35 -0000
@@ -22,39 +22,29 @@
 
 	% Create an empty bag.
 	%
-:- pred bag__init(bag(T)).
-:- mode bag__init(out) is det.
-
+:- pred bag__init(bag(T)::out) is det.
 :- func bag__init = bag(T).
 
 	% Insert a particular value in a bag.
 	%
-:- pred bag__insert(bag(T), T, bag(T)).
-:- mode bag__insert(in, in, out) is det.
-
+:- pred bag__insert(bag(T)::in, T::in, bag(T)::out) is det.
 :- func bag__insert(bag(T), T) = bag(T).
 
 	% Insert a list of values into a bag.
 	%
-:- pred bag__insert_list(bag(T), list(T), bag(T)).
-:- mode bag__insert_list(in, in, out) is det.
-
+:- pred bag__insert_list(bag(T)::in, list(T)::in, bag(T)::out) is det.
 :- func bag__insert_list(bag(T), list(T)) = bag(T).
 
 	% Make a bag from a list.
 	%
-:- pred bag__from_list(list(T), bag(T)).
-:- mode bag__from_list(in, out) is det.
-
+:- pred bag__from_list(list(T)::in, bag(T)::out) is det.
 :- func bag__from_list(list(T)) = bag(T).
 
 	% Given a bag, produce a sorted list containing all the values in
 	% the bag.  Each value will appear in the list the same number of
 	% times that it appears in the bag.
 	%
-:- pred bag__to_list(bag(T), list(T)).
-:- mode bag__to_list(in, out) is det.
-
+:- pred bag__to_list(bag(T)::in, list(T)::out) is det.
 :- func bag__to_list(bag(T)) = list(T).
 
 	% Given a bag, produce a sorted list containing all the values in
@@ -62,31 +52,24 @@
 	% associated integer giving the number of times that it appears
 	% in the bag.
 	%
-:- pred bag__to_assoc_list(bag(T), assoc_list(T, int)).
-:- mode bag__to_assoc_list(in, out) is det.
-
+:- pred bag__to_assoc_list(bag(T)::in, assoc_list(T, int)::out) is det.
 :- func bag__to_assoc_list(bag(T)) = assoc_list(T, int).
 
 	% Given a bag, produce a sorted list with no duplicates
 	% containing all the values in the bag.
 	%
-:- pred bag__to_list_without_duplicates(bag(T), list(T)).
-:- mode bag__to_list_without_duplicates(in, out) is det.
-
+:- pred bag__to_list_without_duplicates(bag(T)::in, list(T)::out) is det.
 :- func bag__to_list_without_duplicates(bag(T)) = list(T).
 
 	% Remove one occurrence of a particular value from a bag.
 	% Fail if the item does not exist in the bag.
 	%
-:- pred bag__remove(bag(T), T, bag(T)).
-:- mode bag__remove(in, in, out) is semidet.
+:- pred bag__remove(bag(T)::in, T::in, bag(T)::out) is semidet.
 
 	% Remove one occurrence of a particular value from a bag.
 	% Abort if the item does not exist in the bag.
 	%
-:- pred bag__det_remove(bag(T), T, bag(T)).
-:- mode bag__det_remove(in, in, out) is det.
-
+:- pred bag__det_remove(bag(T)::in, T::in, bag(T)::out) is det.
 :- func bag__det_remove(bag(T), T) = bag(T).
 
 	% Remove a list of values from a bag.  Duplicates are removed
@@ -100,8 +83,7 @@
 	%		bag__is_subbag(RemoveBag, Bag0),
 	%		bag__subtract(Bag0, RemoveBag, Bag).
 	%
-:- pred bag__remove_list(bag(T), list(T), bag(T)).
-:- mode bag__remove_list(in, in, out) is semidet.
+:- pred bag__remove_list(bag(T)::in, list(T)::in, bag(T)::out) is semidet.
 
 :- func bag__det_remove_list(bag(T), list(T)) = bag(T).
 
@@ -109,40 +91,32 @@
 	% from the bag the appropriate number of times.  Abort if any
 	% of the items in the list do not exist in the bag.
 	%
-:- pred bag__det_remove_list(bag(T), list(T), bag(T)).
-:- mode bag__det_remove_list(in, in, out) is det.
+:- pred bag__det_remove_list(bag(T)::in, list(T)::in, bag(T)::out) is det.
 
 	% Delete one occurrence of a particular value from a bag.
 	% If the key is not present, leave the bag unchanged.
 	%
-:- pred bag__delete(bag(T), T, bag(T)).
-:- mode bag__delete(in, in, out) is det.
-
+:- pred bag__delete(bag(T)::in, T::in, bag(T)::out) is det.
 :- func bag__delete(bag(T), T) = bag(T).
 
 	% Remove all occurrences of a particular value from a bag.
 	% Fail if the item does not exist in the bag.
 	%
-:- pred bag__remove_all(bag(T), T, bag(T)).
-:- mode bag__remove_all(in, in, out) is semidet.
+:- pred bag__remove_all(bag(T)::in, T::in, bag(T)::out) is semidet.
 
 :- func bag__delete_all(bag(T), T) = bag(T).
 
 	% Delete all occurrences of a particular value from a bag.
 	%
-:- pred bag__delete_all(bag(T), T, bag(T)).
-:- mode bag__delete_all(in, in, out) is det.
+:- pred bag__delete_all(bag(T)::in, T::in, bag(T)::out) is det.
 
 	% Check whether a bag contains a particular value.
 	%
-:- pred bag__contains(bag(T), T).
-:- mode bag__contains(in, in) is semidet.
+:- pred bag__contains(bag(T)::in, T::in) is semidet.
 
 	% Count how many occurrences of the value the bag contains.
 	%
-:- pred bag__count_value(bag(T), T, int).
-:- mode bag__count_value(in, in, out) is det.
-
+:- pred bag__count_value(bag(T)::in, T::in, int::out) is det.
 :- func bag__count_value(bag(T), T) = int.
 
 	% bag__subtract(Bag0, SubBag, Bag)
@@ -152,9 +126,7 @@
 	% element is not removed.
 	% e.g. bag__subtract({1, 1, 2, 2, 3 }, {1, 1, 2, 3, 3, 3}, {2}).
 	%
-:- pred bag__subtract(bag(T), bag(T), bag(T)).
-:- mode bag__subtract(in, in, out) is det.
-
+:- pred bag__subtract(bag(T)::in, bag(T)::in, bag(T)::out) is det.
 :- func bag__subtract(bag(T), bag(T)) = bag(T).
 
 	% The third bag is the union of the first 2 bags.
@@ -163,25 +135,20 @@
 	% making the first bag the larger bag will usually be more
 	% efficient.
 	%
-:- pred bag__union(bag(T), bag(T), bag(T)).
-:- mode bag__union(in, in, out) is det.
-
+:- pred bag__union(bag(T)::in, bag(T)::in, bag(T)::out) is det.
 :- func bag__union(bag(T), bag(T)) = bag(T).
 
 	% The third bag is the intersection of the first 2 bags.  Every
 	% element in the third bag exists in both of the first 2 bags.
 	% e.g. bag__intersect({1, 2, 2, 3, 3}, {2, 2, 3, 4}, {2, 2, 3}).
 	%
-:- pred bag__intersect(bag(T), bag(T), bag(T)).
-:- mode bag__intersect(in, in, out) is det.
-
+:- pred bag__intersect(bag(T)::in, bag(T)::in, bag(T)::out) is det.
 :- func bag__intersect(bag(T), bag(T)) = bag(T).
 
 	% Fails if there is no intersection between the 2 bags.
 	% bag__intersect(A, B) :- bag__intersect(A, B, C), not bag__is_empty(C).
 	%
-:- pred bag__intersect(bag(T), bag(T)).
-:- mode bag__intersect(in, in) is semidet.
+:- pred bag__intersect(bag(T)::in, bag(T)::in) is semidet.
 
 	% The third bag is the smallest bag that has both the first two bags
 	% as subbags. If an element X is present N times in one of the first
@@ -191,9 +158,7 @@
 	% making the first bag the larger bag will usually be more
 	% efficient.
 	%
-:- pred bag__least_upper_bound(bag(T), bag(T), bag(T)).
-:- mode bag__least_upper_bound(in, in, out) is det.
-
+:- pred bag__least_upper_bound(bag(T)::in, bag(T)::in, bag(T)::out) is det.
 :- func bag__least_upper_bound(bag(T), bag(T)) = bag(T).
 
 	% Fails if the first bag is not a subbag of the second.
@@ -203,18 +168,15 @@
 	% e.g. bag__is_subbag({1, 1, 2}, {1, 1, 2, 2, 3}).
 	% e.g. bag__is_subbag({1, 1, 2}, {1, 2, 3}) :- fail.
 	%
-:- pred bag__is_subbag(bag(T), bag(T)).
-:- mode bag__is_subbag(in, in) is semidet.
+:- pred bag__is_subbag(bag(T)::in, bag(T)::in) is semidet.
 
 	% Check whether a bag is empty.
 	%
-:- pred bag__is_empty(bag(T)).
-:- mode bag__is_empty(in) is semidet.
+:- pred bag__is_empty(bag(T)::in) is semidet.
 
 	% Fails if the bag is empty.
 	%
-:- pred bag__remove_smallest(bag(T), T, bag(T)).
-:- mode bag__remove_smallest(in, out, out) is semidet.
+:- pred bag__remove_smallest(bag(T)::in, T::out, bag(T)::out) is semidet.
 
 	% Compares the two bags, and returns whether the first bag is a
 	% subset (<), is equal (=), or is a superset (>) of the second.
@@ -223,8 +185,8 @@
 	% bag__subset_compare(>, {apple, apple, orange}, {apple, orange}).
 	% bag__subset_compare(_, {apple, apple}, {orange, orange}) :- fail.
 	%
-:- pred bag__subset_compare(comparison_result, bag(T), bag(T)).
-:- mode bag__subset_compare(out, in, in) is semidet.
+:- pred bag__subset_compare(comparison_result::out, bag(T)::in, bag(T)::in)
+	is semidet.
 
 %---------------------------------------------------------------------------%
 %---------------------------------------------------------------------------%
@@ -265,8 +227,7 @@
 	map__to_assoc_list(Bag, AssocList),
 	bag__to_list_2(AssocList, List).
 
-:- pred bag__to_list_2(assoc_list(T, int), list(T)).
-:- mode bag__to_list_2(in, out) is det.
+:- pred bag__to_list_2(assoc_list(T, int)::in, list(T)::out) is det.
 
 bag__to_list_2([], []).
 bag__to_list_2([X - Int | Xs ], Out) :-
@@ -286,25 +247,23 @@
 
 %---------------------------------------------------------------------------%
 
-bag__delete(Bag0, Item, Bag) :- 	% det
+bag__delete(Bag0, Item, Bag) :-
 	( bag__remove(Bag0, Item, Bag1) ->
 		Bag = Bag1
 	;
 		Bag = Bag0
 	).
 
-bag__remove(Bag0, Item, Bag) :- 	% semidet
+bag__remove(Bag0, Item, Bag) :-
 	map__search(Bag0, Item, Count0),
-	(
-		Count0 > 1
-	->
+	( Count0 > 1 ->
 		Count = Count0 - 1,
 		map__set(Bag0, Item, Count, Bag)
 	;
 		map__delete(Bag0, Item, Bag)
 	).
 
-bag__det_remove(Bag0, Item, Bag) :-	% det
+bag__det_remove(Bag0, Item, Bag) :-
 	( bag__remove(Bag0, Item, Bag1) ->
 		Bag = Bag1
 	;
@@ -379,8 +338,8 @@
 	bag__init(Out0),
 	bag__intersect_2(A, B, Out0, Out).
 
-:- pred bag__intersect_2(bag(T), bag(T), bag(T), bag(T)).
-:- mode bag__intersect_2(in, in, in, out) is det.
+:- pred bag__intersect_2(bag(T)::in, bag(T)::in, bag(T)::in, bag(T)::out)
+	is det.
 
 bag__intersect_2(A, B, Out0, Out) :-
 	( map__remove_smallest(A, Key, AVal,A0) ->
@@ -528,4 +487,3 @@
 
 bag__least_upper_bound(B1, B2) = B3 :-
 	bag__least_upper_bound(B1, B2, B3).
-
Index: library/benchmarking.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/benchmarking.m,v
retrieving revision 1.59
diff -u -b -r1.59 benchmarking.m
--- library/benchmarking.m	20 Feb 2004 06:30:06 -0000	1.59
+++ library/benchmarking.m	9 Mar 2004 13:52:16 -0000
@@ -79,13 +79,15 @@
 
 "). % end pragma foreign_decl
 
-:- pragma foreign_proc("C", report_stats,
+:- pragma foreign_proc("C",
+	report_stats,
 	[will_not_call_mercury],
 "
 	ML_report_stats();
 ").
 
-:- pragma foreign_proc("C", report_full_memory_stats,
+:- pragma foreign_proc("C",
+	report_full_memory_stats,
 	[will_not_call_mercury],
 "
 #ifdef	MR_MPROF_PROFILE_MEMORY
@@ -93,13 +95,15 @@
 #endif
 ").
 
-:- pragma foreign_proc("Java", report_stats,
+:- pragma foreign_proc("Java",
+	report_stats,
 	[may_call_mercury, terminates],
 "
 	ML_report_stats();
 ").
 
-:- pragma foreign_proc("Java", report_full_memory_stats,
+:- pragma foreign_proc("Java",
+	report_full_memory_stats,
 	[will_not_call_mercury],
 "
 	ML_report_full_memory_stats();
@@ -146,7 +150,8 @@
   static void ML_update_counter(MR_memprof_counter *counter,
 				ML_memprof_float_counter *float_counter);
 
-  static int  ML_insert_into_table(const ML_memprof_report_entry *new_entry,
+  static	int	ML_insert_into_table(
+  				const ML_memprof_report_entry *new_entry,
 				ML_memprof_report_entry *table,
 				int table_size, int next_slot);
 
@@ -157,10 +162,11 @@
   static int  ML_memory_profile_fill_table(MR_memprof_record *node,
 				ML_memprof_report_entry *table, int next_slot);
 
-  static void ML_memory_profile_report(const ML_memprof_report_entry *,
+  static	void	ML_memory_profile_report(
+  				const ML_memprof_report_entry *,
 				int num_entries, MR_bool complete);
 
-  static int  ML_memory_profile_compare_final(const void *, const void *);
+  static	int	mpare_final(const void *, const void *);
 
 #endif /* MR_MPROF_PROFILE_MEMORY */
 
@@ -205,7 +211,9 @@
 #endif
 
 #ifdef MR_CONSERVATIVE_GC
-	{ char local_var;
+	{
+		char local_var;
+
 	  fprintf(stderr, "" C Stack: %.3fk,"",
 		labs(&local_var - (char *) GC_stackbottom) / 1024.0);
 	}
@@ -521,13 +529,15 @@
 
 	if (complete) {
 		if (ML_overall_counter.cells_at_period_end < 1.0
-		||  ML_overall_counter.words_at_period_end < 1.0) {
+		||  ML_overall_counter.words_at_period_end < 1.0)
+		{
 			fprintf(stderr, ""no allocations to report\\n"");
 			return;
 		}
 	} else {
 		if (ML_overall_counter.cells_since_period_start < 1.0
-		||  ML_overall_counter.words_since_period_start < 1.0) {
+		||  ML_overall_counter.words_since_period_start < 1.0)
+		{
 			fprintf(stderr, ""no allocations to report\\n"");
 			return;
 		}
@@ -665,6 +675,7 @@
 	).
 
 :- pragma promise_pure(benchmark_func/5).
+
 benchmark_func(Func, In, Out, Repeats, Time) :-
 	impure get_user_cpu_miliseconds(StartTime),
 	impure benchmark_func_loop(Func, In, Out, Repeats),
@@ -687,6 +698,7 @@
 	).
 
 :- pragma promise_pure(benchmark_det_io/7).
+
 benchmark_det_io(Pred, InA, OutA, InB, OutB, Repeats, Time) :-
 	impure get_user_cpu_miliseconds(StartTime),
 	impure benchmark_det_loop_io(Pred, InA, OutA, InB, OutB, Repeats),
@@ -713,6 +725,7 @@
 	).
 
 :- pragma promise_pure(benchmark_nondet/5).
+
 benchmark_nondet(Pred, In, Count, Repeats, Time) :-
 	impure get_user_cpu_miliseconds(StartTime),
 	impure benchmark_nondet_loop(Pred, In, Count, Repeats),
@@ -738,20 +751,24 @@
 	semipure ref_value(SolutionCounter, Count).
 
 :- impure pred repeat(int::in) is nondet.
+
 repeat(N) :-
 	N > 0,
 	( true ; impure repeat(N - 1) ).
 
 :- impure pred get_user_cpu_miliseconds(int::out) is det.
+
 :- pragma foreign_proc("C",
-	get_user_cpu_miliseconds(Time::out), [will_not_call_mercury],
+	get_user_cpu_miliseconds(Time::out),
+	[will_not_call_mercury],
 "
 	Time = MR_get_user_cpu_miliseconds();
 ").
 /* XXX Can't seem to get this to work -- perhaps Diagnostics isn't yet
  * available in Beta 1 of the .NET framework.
 :- pragma foreign_proc("MC++",
-	get_user_cpu_miliseconds(_Time::out), [will_not_call_mercury],
+	get_user_cpu_miliseconds(_Time::out),
+	[will_not_call_mercury],
 "
 	// This won't return the elapsed time since program start,
 	// as it begins timing after the first call.
@@ -760,7 +777,8 @@
 ").
 */
 :- pragma foreign_proc("Java",
-	get_user_cpu_miliseconds(Time::out), [will_not_call_mercury],
+	get_user_cpu_miliseconds(Time::out),
+	[will_not_call_mercury],
 "
 	if (mercury.runtime.Native.isAvailable()) {
 		Time = mercury.runtime.Native.get_user_cpu_miliseconds();
@@ -785,8 +803,11 @@
 ").
 
 :- impure pred do_nothing(T::in) is det.
+
 :- pragma foreign_proc("C", 
-	do_nothing(X::in), [will_not_call_mercury, thread_safe], "
+	do_nothing(X::in),
+	[will_not_call_mercury, thread_safe],
+"
 	ML_benchmarking_dummy_word = (MR_Word) X;
 ").
 /*
@@ -796,7 +817,8 @@
 */
 /*
 :- pragma foreign_proc("MC++", 
-	do_nothing(X::in), [will_not_call_mercury, thread_safe],
+	do_nothing(X::in),
+	[will_not_call_mercury, thread_safe],
 "
 	mercury::runtime::Errors::SORRY(""foreign code for this function"");
 	static volatile MR_Word ML_benchmarking_dummy_word;
@@ -809,7 +831,8 @@
 	static volatile Object ML_benchmarking_dummy_word;
 ").
 :- pragma foreign_proc("Java",
-	do_nothing(X::in), [will_not_call_mercury, thread_safe],
+	do_nothing(X::in),
+	[will_not_call_mercury, thread_safe],
 "
 	ML_benchmarking_dummy_word = X;
 ").
@@ -837,6 +860,7 @@
 %  Create a new int_reference given a term for it to reference.
 :- impure pred new_int_reference(int::in, int_reference::out) is det.
 :- pragma inline(new_int_reference/2).
+
 :- pragma foreign_proc("C",
 	new_int_reference(X::in, Ref::out),
 	[will_not_call_mercury],
@@ -861,6 +885,7 @@
 :- semipure pred ref_value(int_reference::in, int::out) is det.
 :- pragma inline(ref_value/2).
 :- pragma promise_semipure(ref_value/2).
+
 :- pragma foreign_proc("C",
 	ref_value(Ref::in, X::out),
 	[will_not_call_mercury],
@@ -876,6 +901,7 @@
 
 :- impure pred update_ref(int_reference::in, int::in) is det.
 :- pragma inline(update_ref/2).
+
 :- pragma foreign_proc("C",
 	update_ref(Ref::in, X::in),
 	[will_not_call_mercury],
Index: library/bintree.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/bintree.m,v
retrieving revision 1.44
diff -u -b -r1.44 bintree.m
--- library/bintree.m	26 May 2003 09:00:28 -0000	1.44
+++ library/bintree.m	9 Mar 2004 14:13:16 -0000
@@ -15,15 +15,14 @@
 % This file provides a straight-forward binary search tree implementation of
 % a map (dictionary).
 %
-% bintree__insert, bintree__update, and
-% bintree__set differ only in how they handle the case where the value
-% being inserted already exists in the tree.  `insert' will only insert
-% new keys, and will fail if you attempt to insert an existing key into
-% the tree. `update' will only allow you to modify the data for existing
-% keys, and will fail if the key isn't already in the tree.  `set' will
-% always succeed; it will replace the old value for that key if the key
-% was already in the tree, or insert a new node into the tree if the key
-% wasn't already present.
+% bintree__insert, bintree__update, and bintree__set differ only in how they
+% handle the case where the value being inserted already exists in the tree.
+% `insert' will only insert new keys, and will fail if you attempt to insert
+% an existing key into the tree. `update' will only allow you to modify the
+% data for existing keys, and will fail if the key isn't already in the tree.
+% `set' will always succeed; it will replace the old value for that key
+% if the key was already in the tree, or insert a new node into the tree
+% if the key wasn't already present.
 % 
 %-----------------------------------------------------------------------------%
 
@@ -33,124 +32,104 @@
 
 :- type bintree(K, V).
 
-:- pred bintree__init(bintree(K,V)).
-:- mode bintree__init(uo) is det.
+:- pred bintree__init(bintree(K, V)::uo) is det.
 
-:- pred bintree__insert(bintree(K,V), K, V, bintree(K,V)).
-:- mode bintree__insert(in, in, in, out) is semidet.
+:- pred bintree__insert(bintree(K, V)::in, K::in, V::in, bintree(K, V)::out)
+	is semidet.
 
-:- pred bintree__update(bintree(K,V), K, V, bintree(K,V)).
-:- mode bintree__update(in, in, in, out) is semidet.
+:- pred bintree__update(bintree(K, V)::in, K::in, V::in, bintree(K, V)::out)
+	is semidet.
 
-:- pred bintree__set(bintree(K,V), K, V, bintree(K,V)).
+:- pred bintree__set(bintree(K, V), K, V, bintree(K, V)).
 :- mode bintree__set(di, di, di, uo) is det.
 :- mode bintree__set(in, in, in, out) is det.
 
-:- func bintree__set(bintree(K,V), K, V) = bintree(K,V).
+:- func bintree__set(bintree(K, V), K, V) = bintree(K, V).
 
-:- pred bintree__search(bintree(K,V), K, V).
+:- pred bintree__search(bintree(K, V), K, V).
 :- mode bintree__search(in, in, in) is semidet.	% implied
 :- mode bintree__search(in, in, out) is semidet.
 
-:- pred bintree__lookup(bintree(K,V), K, V).
-:- mode bintree__lookup(in, in, out) is det.
-
-:- func bintree__lookup(bintree(K,V), K) = V.
+:- pred bintree__lookup(bintree(K, V)::in, K::in, V::out) is det.
+:- func bintree__lookup(bintree(K, V), K) = V.
 
 	% Search for a key-value pair using the key.  If there is no entry
 	% for the given key, returns the pair for the next lower key instead.
 	% Fails if there is no key with the given or lower value.
-:- pred bintree__lower_bound_search(bintree(K,V), K, K, V).
-:- mode bintree__lower_bound_search(in, in, out, out) is semidet.
+:- pred bintree__lower_bound_search(bintree(K, V)::in, K::in, K::out, V::out)
+	is semidet.
 
 	% Search for a key-value pair using the key.  If there is no entry
 	% for the given key, returns the pair for the next lower key instead.
 	% Aborts if there is no key with the given or lower value.
-:- pred bintree__lower_bound_lookup(bintree(K,V), K, K, V).
-:- mode bintree__lower_bound_lookup(in, in, out, out) is det.
+:- pred bintree__lower_bound_lookup(bintree(K, V)::in, K::in, K::out, V::out)
+	is det.
 
 	% Search for a key-value pair using the key.  If there is no entry
 	% for the given key, returns the pair for the next higher key instead.
 	% Fails if there is no key with the given or higher value.
-:- pred bintree__upper_bound_search(bintree(K,V), K, K, V).
-:- mode bintree__upper_bound_search(in, in, out, out) is semidet.
+:- pred bintree__upper_bound_search(bintree(K, V)::in, K::in, K::out, V::out)
+	is semidet.
 
 	% Search for a key-value pair using the key.  If there is no entry
 	% for the given key, returns the pair for the next higher key instead.
 	% Aborts if there is no key with the given or higher value.
-:- pred bintree__upper_bound_lookup(bintree(K,V), K, K, V).
-:- mode bintree__upper_bound_lookup(in, in, out, out) is det.
-
-:- pred bintree__delete(bintree(K,V), K, bintree(K,V)).
-:- mode bintree__delete(in, in, out) is det.
-
-:- func bintree__delete(bintree(K,V), K) = bintree(K,V).
-
-:- pred bintree__remove(bintree(K,V), K, V, bintree(K,V)).
-:- mode bintree__remove(in, in, out, out) is semidet.
-
-:- pred bintree__keys(bintree(K,_V), list(K)).
-:- mode bintree__keys(in, out) is det.
-
-:- func bintree__keys(bintree(K,_V)) = list(K).
+:- pred bintree__upper_bound_lookup(bintree(K, V)::in, K::in, K::out, V::out)
+	is det.
 
-:- pred bintree__values(bintree(_K,V), list(V)).
-:- mode bintree__values(in, out) is det.
+:- pred bintree__delete(bintree(K, V)::in, K::in, bintree(K, V)::out) is det.
+:- func bintree__delete(bintree(K, V), K) = bintree(K, V).
 
-:- func bintree__values(bintree(_K,V)) = list(V).
+:- pred bintree__remove(bintree(K, V)::in, K::in, V::out, bintree(K, V)::out)
+	is semidet.
 
-:- pred bintree__from_list(assoc_list(K,V), bintree(K,V)).
-:- mode bintree__from_list(in, out) is det.
+:- pred bintree__keys(bintree(K, _V)::in, list(K)::out) is det.
+:- func bintree__keys(bintree(K, _V)) = list(K).
 
-:- func bintree__from_list(assoc_list(K,V)) = bintree(K,V).
+:- pred bintree__values(bintree(_K, V)::in, list(V)::out) is det.
+:- func bintree__values(bintree(_K, V)) = list(V).
 
-:- pred bintree__from_sorted_list(assoc_list(K,V), bintree(K,V)).
-:- mode bintree__from_sorted_list(in, out) is det.
+:- pred bintree__from_list(assoc_list(K, V)::in, bintree(K, V)::out) is det.
+:- func bintree__from_list(assoc_list(K, V)) = bintree(K, V).
 
-:- func bintree__from_sorted_list(assoc_list(K,V)) = bintree(K,V).
+:- pred bintree__from_sorted_list(assoc_list(K, V)::in, bintree(K, V)::out)
+	is det.
+:- func bintree__from_sorted_list(assoc_list(K, V)) = bintree(K, V).
 
-:- pred bintree__from_corresponding_lists(list(K), list(V), bintree(K,V)).
-:- mode bintree__from_corresponding_lists(in, in, out) is det.
+:- pred bintree__from_corresponding_lists(list(K)::in, list(V)::in,
+	bintree(K, V)::out) is det.
+:- func bintree__from_corresponding_lists(list(K), list(V)) = bintree(K, V).
 
-:- func bintree__from_corresponding_lists(list(K), list(V)) = bintree(K,V).
-
-:- pred bintree__to_list(bintree(K,V), assoc_list(K,V)).
-:- mode bintree__to_list(in, out) is det.
-
-:- func bintree__to_list(bintree(K,V)) = assoc_list(K,V).
+:- pred bintree__to_list(bintree(K, V)::in, assoc_list(K, V)::out) is det.
+:- func bintree__to_list(bintree(K, V)) = assoc_list(K, V).
 
 	% count the number of elements in a tree
-:- pred bintree__count(bintree(_K,_V), int).
-:- mode bintree__count(in, out) is det.
-
-:- func bintree__count(bintree(_K,_V)) = int.
+:- pred bintree__count(bintree(_K, _V)::in, int::out) is det.
+:- func bintree__count(bintree(_K, _V)) = int.
 
 	% count the depth of a tree
-:- pred bintree__depth(bintree(_K,_V), int).
-:- mode bintree__depth(in, out) is det.
-
-:- func bintree__depth(bintree(_K,_V)) = int.
-
-:- pred bintree__branching_factor(bintree(_K,_V), int, int).
-:- mode bintree__branching_factor(in, out, out) is det.
+:- pred bintree__depth(bintree(_K, _V)::in, int::out) is det.
+:- func bintree__depth(bintree(_K, _V)) = int.
 
-:- pred bintree__balance(bintree(K, V), bintree(K, V)).
-:- mode bintree__balance(in, out) is det.
+:- pred bintree__branching_factor(bintree(_K, _V)::in, int::out, int::out)
+	is det.
 
+:- pred bintree__balance(bintree(K, V)::in, bintree(K, V)::out) is det.
 :- func bintree__balance(bintree(K, V)) = bintree(K, V).
 
 %-----------------------------------------------------------------------------%
 
 :- implementation.
 
-:- import_module require, int, std_util.
+:- import_module require, int, string, std_util.
 
-:- type bintree(K,V)		--->	empty
+:- type bintree(K, V)
+	--->	empty
 				;	tree(
 						K,
 						V,
-						bintree(K,V),
-						bintree(K,V)
+			bintree(K, V),
+			bintree(K, V)
 					).
 
 %-----------------------------------------------------------------------------%
@@ -162,13 +141,9 @@
 bintree__insert(empty, Key, Value, tree(Key, Value, empty, empty)).
 bintree__insert(tree(Key0, Value0, Left, Right), Key, Value, Tree) :-
 	compare(Result, Key0, Key),
-	(
-		Result = (=)
-	->
+	( Result = (=) ->
 		fail
-	;
-		Result = (<)
-	->
+	; Result = (<) ->
 		bintree__insert(Right, Key, Value, NewRight),
 		Tree = tree(Key0, Value0, Left, NewRight)
 	;
@@ -182,13 +157,9 @@
 	fail.
 bintree__update(tree(Key0, Value0, Left, Right), Key, Value, Tree) :-
 	compare(Result, Key0, Key),
-	(
-		Result = (=)
-	->
+	( Result = (=) ->
 		Tree = tree(Key0, Value, Left, Right)
-	;
-		Result = (<)
-	->
+	; Result = (<) ->
 		bintree__update(Right, Key, Value, NewRight),
 		Tree = tree(Key0, Value0, Left, NewRight)
 	;
@@ -201,13 +172,9 @@
 bintree__set(empty, Key, Value, tree(Key, Value, empty, empty)).
 bintree__set(tree(Key0, Value0, Left, Right), Key, Value, Tree) :-
 	compare(Result, Key0, Key),
-	(
-		Result = (=)
-	->
+	( Result = (=) ->
 		Tree = tree(Key0, Value, Left, Right)
-	;
-		Result = (<)
-	->
+	; Result = (<) ->
 		bintree__set(Right, Key, Value, NewRight),
 		Tree = tree(Key0, Value0, Left, NewRight)
 	;
@@ -219,13 +186,9 @@
 
 bintree__search(tree(K0, V0, Left, Right), K, V) :-
 	compare(Result, K0, K),
-	(
-		Result = (=)
-	->
+	( Result = (=) ->
 		V = V0
-	;
-		Result = (<)
-	->
+	; Result = (<) ->
 		bintree__search(Right, K, V)
 	;
 		bintree__search(Left, K, V)
@@ -244,14 +207,10 @@
 
 bintree__lower_bound_search(tree(K0, V0, Left, Right), SearchK, K, V) :-
 	compare(Result, K0, SearchK),
-	(
-		Result = (=)
-	->
+	( Result = (=) ->
 		K = K0,
 		V = V0
-	;
-		Result = (<)
-	->
+	; Result = (<) ->
 		( bintree__lower_bound_search(Right, SearchK, Kp, Vp) ->
 			K = Kp,
 			V = Vp
@@ -268,22 +227,18 @@
 		K = K0,
 		V = V0
 	;
-		report_lookup_error("bintree__lower_bound_lookup: key not found",
-			SearchK, V)
+		report_lookup_error("bintree__lower_bound_lookup: " ++
+			"key not found", SearchK, V)
 	).
 
 %-----------------------------------------------------------------------------%
 
 bintree__upper_bound_search(tree(K0, V0, Left, Right), SearchK, K, V) :-
 	compare(Result, K0, SearchK),
-	(
-		Result = (=)
-	->
+	( Result = (=) ->
 		K = K0,
 		V = V0
-	;
-		Result = (<)
-	->
+	; Result = (<) ->
 		bintree__upper_bound_search(Right, SearchK, K, V)
 	;
 		( bintree__upper_bound_search(Left, SearchK, Kp, Vp) ->
@@ -300,7 +255,8 @@
 		K = K0,
 		V = V0
 	;
-		report_lookup_error("bintree__lower_bound_lookup: key not found",
+		report_lookup_error("bintree__lower_bound_lookup: " ++
+			"key not found",
 			SearchK, V)
 	).
 
@@ -309,13 +265,9 @@
 bintree__delete(empty, _K, empty).
 bintree__delete(tree(K0, V0, Left, Right), K, Tree) :-
 	compare(Result, K0, K),
-	(
-		Result = (=)
-	->
+	( Result = (=) ->
 		bintree__fixup(Left, Right, Tree)
-	;
-		Result = (<)
-	->
+	; Result = (<) ->
 		bintree__delete(Right, K, Tree1),
 		Tree = tree(K0, V0, Left, Tree1)
 	;
@@ -327,14 +279,10 @@
 
 bintree__remove(tree(K0, V0, Left, Right), K, V, Tree) :-
 	compare(Result, K0, K),
-	(
-		Result = (=)
-	->
+	( Result = (=) ->
 		V = V0,
 		bintree__fixup(Left, Right, Tree)
-	;
-		Result = (<)
-	->
+	; Result = (<) ->
 		bintree__remove(Right, K, V, Tree1),
 		Tree = tree(K0, V0, Left, Tree1)
 	;
@@ -344,24 +292,18 @@
 
 %-----------------------------------------------------------------------------%
 
-:- pred bintree__fixup(bintree(K,V), bintree(K,V), bintree(K,V)).
-:- mode bintree__fixup(in, in, out) is det.
+:- pred bintree__fixup(bintree(K, V)::in, bintree(K, V)::in,
+	bintree(K, V)::out) is det.
 
 bintree__fixup(Left, Right, Tree) :-
-	(
-		Left = empty
-	->
+	( Left = empty ->
 		Tree = Right
-	;
-		Right = empty
-	->
+	; Right = empty ->
 		Tree = Left
 	;
 		bintree__right_depth(Left, LD),
 		bintree__left_depth(Right, RD),
-		(
-			LD > RD
-		->
+		( LD > RD ->
 			bintree__knock_left(Left, K, V, Left1),
 			Right1 = Right
 		;
@@ -371,31 +313,27 @@
 		Tree = tree(K, V, Left1, Right1)
 	).
 
-:- pred bintree__right_depth(bintree(_K,_V), int).
-:- mode bintree__right_depth(in, out) is det.
+:- pred bintree__right_depth(bintree(_K, _V)::in, int::out) is det.
 
 bintree__right_depth(empty, 0).
 bintree__right_depth(tree(_K, _V, _Left, Right), N) :-
 	bintree__right_depth(Right, M),
 	N = M + 1.
 
-:- pred bintree__left_depth(bintree(_K,_V), int).
-:- mode bintree__left_depth(in, out) is det.
+:- pred bintree__left_depth(bintree(_K, _V)::in, int::out) is det.
 
 bintree__left_depth(empty, 0).
 bintree__left_depth(tree(_K, _V, Left, _Right), N) :-
 	bintree__left_depth(Left, M),
 	N = M + 1.
 
-:- pred bintree__knock_left(bintree(K,V), K, V, bintree(K, V)).
-:- mode bintree__knock_left(in, out, out, out) is det.
+:- pred bintree__knock_left(bintree(K, V)::in, K::out, V::out,
+	bintree(K, V)::out) is det.
 
 bintree__knock_left(empty, _, _, _) :-
 	error("bintree__knock_left: empty tree").
 bintree__knock_left(tree(K0, V0, Left, Right), K, V, Tree) :-
-	(
-		Right = empty
-	->
+	( Right = empty ->
 		K = K0,
 		V = V0,
 		Tree = Left
@@ -404,15 +342,13 @@
 		Tree = tree(K0, V0, Left, Right1)
 	).
 
-:- pred bintree__knock_right(bintree(K,V), K, V, bintree(K, V)).
-:- mode bintree__knock_right(in, out, out, out) is det.
+:- pred bintree__knock_right(bintree(K, V)::in, K::out, V::out,
+	bintree(K, V)::out) is det.
 
 bintree__knock_right(empty, _, _, _) :-
 	error("bintree__knock_right: empty tree").
 bintree__knock_right(tree(K0, V0, Left, Right), K, V, Tree) :-
-	(
-		Left = empty
-	->
+	( Left = empty ->
 		K = K0,
 		V = V0,
 		Tree = Right
@@ -426,8 +362,8 @@
 bintree__from_list(List, Tree) :-
 	bintree__from_list_2(List, empty, Tree).
 
-:- pred bintree__from_list_2(assoc_list(K,V), bintree(K,V), bintree(K,V)).
-:- mode bintree__from_list_2(in, in, out) is det.
+:- pred bintree__from_list_2(assoc_list(K, V)::in, bintree(K, V)::in,
+	bintree(K, V)::out) is det.
 
 bintree__from_list_2([], Tree, Tree).
 bintree__from_list_2([K - V | List], Tree0, Tree) :-
@@ -445,9 +381,8 @@
 	list__length(List, Length),
 	bintree__from_sorted_list_2(Length, List, Tree, _).
 
-:- pred bintree__from_sorted_list_2(int, assoc_list(K,V),
-				bintree(K,V), assoc_list(K, V)).
-:- mode bintree__from_sorted_list_2(in, in, out, out) is det.
+:- pred bintree__from_sorted_list_2(int::in, assoc_list(K, V)::in,
+	bintree(K, V)::out, assoc_list(K, V)::out) is det.
 
 bintree__from_sorted_list_2(Num, List0, Tree, List) :-
 	( Num = 0 ->
@@ -481,19 +416,20 @@
 	( bintree__from_corresponding_lists_2(Keys, Values, empty, Tree0) ->
 		Tree = Tree0
 	;
-		error("bintree__from_corresponding_lists: lists are of different lengths")
+		error("bintree__from_corresponding_lists: " ++
+			"lists are of different lengths")
 	).
 
-:- pred bintree__from_corresponding_lists_2(list(K), list(V), bintree(K,V),
-						bintree(K,V)).
-:- mode bintree__from_corresponding_lists_2(in, in, in, out) is semidet.
+:- pred bintree__from_corresponding_lists_2(list(K)::in, list(V)::in,
+	bintree(K, V)::in, bintree(K, V)::out) is semidet.
 
 bintree__from_corresponding_lists_2([], [], Tree, Tree).
 bintree__from_corresponding_lists_2([K | Ks], [V | Vs], Tree0, Tree) :-
 	( bintree__insert(Tree0, K, V, Tree1) ->
 		Tree2 = Tree1
 	;
-		report_lookup_error("bintree__from_corresponding_lists: key already present", K, V)
+		report_lookup_error("bintree__from_corresponding_lists: " ++
+			"key already present", K, V)
 	),
 	bintree__from_corresponding_lists_2(Ks, Vs, Tree2, Tree).
 
@@ -502,8 +438,8 @@
 bintree__to_list(Tree, List) :-
 	bintree__to_list_2(Tree, [], List).
 
-:- pred bintree__to_list_2(bintree(K,V), assoc_list(K,V), assoc_list(K,V)).
-:- mode bintree__to_list_2(in, in, out) is det.
+:- pred bintree__to_list_2(bintree(K, V)::in, assoc_list(K, V)::in,
+	assoc_list(K, V)::out) is det.
 
 bintree__to_list_2(empty, List, List).
 bintree__to_list_2(tree(K, V, Left, Right), List0, List) :-
@@ -515,8 +451,7 @@
 bintree__keys(Tree, List) :-
 	bintree__keys_2(Tree, [], List).
 
-:- pred bintree__keys_2(bintree(K, _V), list(K), list(K)).
-:- mode bintree__keys_2(in, in, out) is det.
+:- pred bintree__keys_2(bintree(K, _V)::in, list(K)::in, list(K)::out) is det.
 
 bintree__keys_2(empty, List, List).
 bintree__keys_2(tree(K, _V, Left, Right), List0, List) :-
@@ -528,8 +463,8 @@
 bintree__values(Tree, List) :-
 	bintree__values_2(Tree, [], List).
 
-:- pred bintree__values_2(bintree(_K, V), list(V), list(V)).
-:- mode bintree__values_2(in, in, out) is det.
+:- pred bintree__values_2(bintree(_K, V)::in, list(V)::in, list(V)::out)
+	is det.
 
 bintree__values_2(empty, List, List).
 bintree__values_2(tree(_K, V, Left, Right), List0, List) :-
@@ -554,12 +489,8 @@
 
 bintree__branching_factor(empty, 0, 0).
 bintree__branching_factor(tree(_K, _V, L, R), Ones, Twos) :-
-	(
-		L = empty
-	->
-		(
-			R = empty
-		->
+	( L = empty ->
+		( R = empty ->
 			Ones = 0,
 			Twos = 0
 		;
@@ -567,9 +498,7 @@
 			Ones = Ones0 + 1
 		)
 	;
-		(
-			R = empty
-		->
+		( R = empty ->
 			bintree__branching_factor(L, Ones0, Twos),
 			Ones = Ones0 + 1
 		;
@@ -621,4 +550,3 @@
 
 bintree__balance(BT1) = BT2 :-
 	bintree__balance(BT1, BT2).
-
Index: library/bintree_set.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/bintree_set.m,v
retrieving revision 1.20
diff -u -b -r1.20 bintree_set.m
--- library/bintree_set.m	11 Nov 2003 03:35:13 -0000	1.20
+++ library/bintree_set.m	9 Mar 2004 13:46:21 -0000
@@ -29,56 +29,46 @@
 	% `bintree_set__list_to_set(List, Set)' is true iff `Set' is the set 
 	% containing only the members of `List'.
 
-:- pred bintree_set__list_to_set(list(T), bintree_set(T)).
-:- mode bintree_set__list_to_set(in, out) is det.
-
+:- pred bintree_set__list_to_set(list(T)::in, bintree_set(T)::out) is det.
 :- func bintree_set__list_to_set(list(T)) = bintree_set(T).
 
 	% `bintree_set__sorted_list_to_set(List, Set)' is true iff
 	% `Set' is the set containing only the members of `List'.
 	% `List' must be sorted.
 
-:- pred bintree_set__sorted_list_to_set(list(T), bintree_set(T)).
-:- mode bintree_set__sorted_list_to_set(in, out) is det.
-
+:- pred bintree_set__sorted_list_to_set(list(T)::in, bintree_set(T)::out)
+	is det.
 :- func bintree_set__sorted_list_to_set(list(T)) = bintree_set(T).
 
 	% `bintree_set__list_to_bintree_set(Set, List)' is true iff
 	% `List' is the list of all the members of `Set', in sorted
 	% order.
 
-:- pred bintree_set__to_sorted_list(bintree_set(T), list(T)).
-:- mode bintree_set__to_sorted_list(in, out) is det.
-
+:- pred bintree_set__to_sorted_list(bintree_set(T)::in, list(T)::out) is det.
 :- func bintree_set__to_sorted_list(bintree_set(T)) = list(T).
 
 	% `bintree_set__init(Set)' is true iff `Set' is an empty set.
 
-:- pred bintree_set__init(bintree_set(T)).
-:- mode bintree_set__init(uo) is det.
-
+:- pred bintree_set__init(bintree_set(T)::uo) is det.
 :- func bintree_set__init = bintree_set(T).
 
-:- pred bintree_set__singleton_set(bintree_set(T), T).
-:- mode bintree_set__singleton_set(out, in) is det.
+:- pred bintree_set__singleton_set(bintree_set(T)::out, T::in) is det.
 
 	% `bintree_set__equal(SetA, SetB)' is true iff
 	% `SetA' and `SetB' contain the same elements.
 
-:- pred bintree_set__equal(bintree_set(T), bintree_set(T)).
-:- mode bintree_set__equal(in, in) is semidet.
+:- pred bintree_set__equal(bintree_set(T)::in, bintree_set(T)::in) is semidet.
 
 	% `bintree_set__subset(SetA, SetB)' is true iff `SetA' is a
 	% subset of `SetB'.
 
-:- pred bintree_set__subset(bintree_set(T), bintree_set(T)).
-:- mode bintree_set__subset(in, in) is semidet.
+:- pred bintree_set__subset(bintree_set(T)::in, bintree_set(T)::in) is semidet.
 
 	% `bintree_set__superset(SetA, SetB)' is true iff `SetA' is a
 	% superset of `SetB'.
 
-:- pred bintree_set__superset(bintree_set(T), bintree_set(T)).
-:- mode bintree_set__superset(in, in) is semidet.
+:- pred bintree_set__superset(bintree_set(T)::in, bintree_set(T)::in)
+	is semidet.
 
 	% `bintree_set_member(X, Set)' is true iff `X' is a member of `Set'.
 
@@ -89,14 +79,12 @@
 	% `bintree_set__is_member(X, Set)' is true
 	% iff `X' is a member of `Set'.
 
-:- pred bintree_set__is_member(T, bintree_set(T)).
-:- mode bintree_set__is_member(in, in) is semidet.
+:- pred bintree_set__is_member(T::in, bintree_set(T)::in) is semidet.
 
 	% `bintree_set__contains(Set, X)' is true
 	% iff `X' is a member of `Set'.
 
-:- pred bintree_set__contains(bintree_set(T), T).
-:- mode bintree_set__contains(in, in) is semidet.
+:- pred bintree_set__contains(bintree_set(T)::in, T::in) is semidet.
 
 	% `bintree_set__insert(Set0, X, Set)' is true iff `Set' is the union of
 	% `Set0' and the set containing only `X'.
@@ -132,45 +120,41 @@
 	% `Xs', and `Set' is the relative complement of `Set0' and the
 	% set containing only the members of `Xs'.
 
-:- pred bintree_set__remove_list(bintree_set(T), list(T), bintree_set(T)).
-:- mode bintree_set__remove_list(in, in, out) is semidet.
+:- pred bintree_set__remove_list(bintree_set(T)::in, list(T)::in,
+	bintree_set(T)::out) is semidet.
 
 	% `bintree_set__delete(Set0, X, Set)' is true iff `Set' is the relative
 	% complement of `Set0' and the set containing only `X', i.e.
 	% if `Set' is the set which contains all the elements of `Set0'
 	% except `X'.
 
-:- pred bintree_set__delete(bintree_set(T), T, bintree_set(T)).
-:- mode bintree_set__delete(in, in, out) is det.
-
+:- pred bintree_set__delete(bintree_set(T)::in, T::in, bintree_set(T)::out)
+	is det.
 :- func bintree_set__delete(bintree_set(T), T) = bintree_set(T).
 
 	% `bintree_set__delete_list(Set0, Xs, Set)' is true iff `Set'
 	% is the relative complement of `Set0' and the set containing
 	% only the members of `Xs'.
 
-:- pred bintree_set__delete_list(bintree_set(T), list(T), bintree_set(T)).
-:- mode bintree_set__delete_list(in, in, out) is det.
-
+:- pred bintree_set__delete_list(bintree_set(T)::in, list(T)::in,
+	bintree_set(T)::out) is det.
 :- func bintree_set__delete_list(bintree_set(T), list(T)) = bintree_set(T).
 
 	% `set_union(SetA, SetB, Set)' is true iff `Set' is the union of
 	% `SetA' and `SetB'.  If the sets are known to be of different
 	% sizes, then for efficiency make `SetA' the larger of the two.
 
-:- pred bintree_set__union(bintree_set(T), bintree_set(T), bintree_set(T)).
-:- mode bintree_set__union(in, in, out) is det.
-
+:- pred bintree_set__union(bintree_set(T)::in, bintree_set(T)::in,
+	bintree_set(T)::out) is det.
 :- func bintree_set__union(bintree_set(T), bintree_set(T)) = bintree_set(T).
 
 	% `set_intersect(SetA, SetB, Set)' is true iff `Set' is the
 	% intersection of `SetA' and `SetB'.
 
-:- pred bintree_set__intersect(bintree_set(T), bintree_set(T),
-				bintree_set(T)).
-:- mode bintree_set__intersect(in, in, out) is det.
-
-:- func bintree_set__intersect(bintree_set(T), bintree_set(T)) = bintree_set(T).
+:- pred bintree_set__intersect(bintree_set(T)::in, bintree_set(T)::in,
+	bintree_set(T)::out) is det.
+:- func bintree_set__intersect(bintree_set(T), bintree_set(T))
+	= bintree_set(T).
 
 %--------------------------------------------------------------------------%
 
@@ -193,8 +177,7 @@
 bintree_set__to_sorted_list(Set, List) :-
 	bintree__keys(Set, List).
 
-:- pred assoc_unit(list(T), assoc_list(T, unit)).
-:- mode assoc_unit(in, out) is det.
+:- pred assoc_unit(list(T)::in, assoc_list(T, unit)::out) is det.
 
 assoc_unit([], []).
 assoc_unit([X | Xs], [X - unit | Ys]) :-
@@ -219,8 +202,7 @@
 	bintree__keys(S0, SortedElements0),
 	bintree_set__contains_list(SortedElements0, S1).
 
-:- pred bintree_set__contains_list(list(T), bintree_set(T)).
-:- mode bintree_set__contains_list(in, in) is semidet.
+:- pred bintree_set__contains_list(list(T)::in, bintree_set(T)::in) is semidet.
 
 bintree_set__contains_list([E|Es], S) :-
 	bintree__search(S, E, _),
Index: library/bitmap.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/bitmap.m,v
retrieving revision 1.7
diff -u -b -r1.7 bitmap.m
--- library/bitmap.m	29 Oct 2002 16:51:26 -0000	1.7
+++ library/bitmap.m	9 Mar 2004 13:52:52 -0000
@@ -1,10 +1,10 @@
 %-----------------------------------------------------------------------------%
+% vim: ts=4 sw=4 et tw=0 wm=0 ft=mercury
+%-----------------------------------------------------------------------------%
 % Copyright (C) 2001-2002 The University of Melbourne
 % This file may only be copied under the terms of the GNU Library General
 % Public License - see the file COPYING.LIB in the Mercury distribution.
 %-----------------------------------------------------------------------------%
-% vim: ts=4 sw=4 et tw=0 wm=0 ft=mercury
-%-----------------------------------------------------------------------------%
 %
 % File: bitmap.m
 % Main author: rafe
@@ -27,8 +27,6 @@
 
 :- import_module array, int, bool.
 
-
-
 :- type bitmap.
 
 :- inst bitmap    == array.
@@ -292,8 +290,6 @@
 
 complement(BM) =
     clear_filler_bits(complement_2(BM ^ elem(0) - 1, BM)).
-
-
 
 :- func complement_2(int, bitmap) = bitmap.
 :- mode complement_2(in, bitmap_di) = bitmap_uo is det.
Index: library/char.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/char.m,v
retrieving revision 1.45
diff -u -b -r1.45 char.m
--- library/char.m	12 Dec 2003 02:20:30 -0000	1.45
+++ library/char.m	9 Mar 2004 13:57:23 -0000
@@ -31,11 +31,6 @@
 
 :- instance enum(character).
 
-:- func char__to_int(char) = int.
-:- pred char__to_int(char, int).
-:- mode char__to_int(in, out) is det.
-:- mode char__to_int(in, in) is semidet.	% implied
-:- mode char__to_int(out, in) is semidet.
 	% Convert a character to its corresponding numerical code
 	% (integer value).
 	% Beware that the mapping from characters to numerical codes
@@ -48,98 +43,86 @@
 	% to the standard output or standard error streams.
 	% For example, an implementation might represent characters
 	% using Unicode, but store files in an 8-bit national character set.
+:- func char__to_int(char) = int.
+:- pred char__to_int(char, int).
+:- mode char__to_int(in, out) is det.
+:- mode char__to_int(in, in) is semidet.	% implied
+:- mode char__to_int(out, in) is semidet.
 
-:- func char__max_char_value = int.
-:- pred char__max_char_value(int).
-:- mode char__max_char_value(out) is det.
 	% Returns the maximum numerical character code.
+:- func char__max_char_value = int.
+:- pred char__max_char_value(int::out) is det.
 
-:- func char__min_char_value = int.
-:- pred char__min_char_value(int).
-:- mode char__min_char_value(out) is det.
 	% Returns the minimum numerical character code.
+:- func char__min_char_value = int.
+:- pred char__min_char_value(int::out) is det.
 
-:- func char__to_upper(char) = char.
-:- pred char__to_upper(char, char).
-:- mode char__to_upper(in, out) is det.
 	% Convert a character to uppercase.
+:- func char__to_upper(char) = char.
+:- pred char__to_upper(char::in, char::out) is det.
 
-:- func char__to_lower(char) = char.
-:- pred char__to_lower(char, char).
-:- mode char__to_lower(in, out) is det.
 	% Convert a character to lowercase.
+:- func char__to_lower(char) = char.
+:- pred char__to_lower(char::in, char::out) is det.
 
-:- pred char__lower_upper(char, char).
-:- mode char__lower_upper(in, out) is semidet.
-:- mode char__lower_upper(out, in) is semidet.
 	% char__lower_upper(Lower, Upper) is true iff
 	% Lower is a lower-case letter and Upper is the corresponding
 	% upper-case letter.
+:- pred char__lower_upper(char, char).
+:- mode char__lower_upper(in, out) is semidet.
+:- mode char__lower_upper(out, in) is semidet.
 
-:- pred char__is_whitespace(char).
-:- mode char__is_whitespace(in) is semidet.
 	% True iff the character is whitespace, i.e. a space, tab,
 	% newline, carriage return, form-feed, or vertical tab.
+:- pred char__is_whitespace(char::in) is semidet.
 
-:- pred char__is_upper(char).
-:- mode char__is_upper(in) is semidet.
 	% True iff the character is an uppercase letter.
+:- pred char__is_upper(char::in) is semidet.
 
-:- pred char__is_lower(char).
-:- mode char__is_lower(in) is semidet.
 	% True iff the character is a lowercase letter.
+:- pred char__is_lower(char::in) is semidet.
 
-:- pred char__is_alpha(char).
-:- mode char__is_alpha(in) is semidet.
 	% True iff the character is a letter.
+:- pred char__is_alpha(char::in) is semidet.
 
-:- pred char__is_alnum(char).
-:- mode char__is_alnum(in) is semidet.
 	% True iff the character is a letter or digit.
+:- pred char__is_alnum(char::in) is semidet.
 
-:- pred char__is_alpha_or_underscore(char).
-:- mode char__is_alpha_or_underscore(in) is semidet.
 	% True iff the character is a letter or an underscore.
+:- pred char__is_alpha_or_underscore(char::in) is semidet.
 
-:- pred char__is_alnum_or_underscore(char).
-:- mode char__is_alnum_or_underscore(in) is semidet.
 	% True iff the character is a letter, a digit or an underscore.
+:- pred char__is_alnum_or_underscore(char::in) is semidet.
 
-:- pred char__is_digit(char).
-:- mode char__is_digit(in) is semidet.
 	% True iff the character is a decimal digit (0-9).
+:- pred char__is_digit(char::in) is semidet.
 
-:- pred char__is_binary_digit(char).
-:- mode char__is_binary_digit(in) is semidet.
 	% True iff the character is a binary digit (0 or 1).
+:- pred char__is_binary_digit(char::in) is semidet.
 
-:- pred char__is_octal_digit(char).
-:- mode char__is_octal_digit(in) is semidet.
 	% True iff the character is a octal digit (0-7).
+:- pred char__is_octal_digit(char::in) is semidet.
 
-:- pred char__is_hex_digit(char).
-:- mode char__is_hex_digit(in) is semidet.
 	% True iff the character is a hexadecimal digit (0-9, a-f, A-F).
+:- pred char__is_hex_digit(char::in) is semidet.
 
-:- pred char__digit_to_int(char, int).
-:- mode char__digit_to_int(in, out) is semidet.
 	% Succeeds if char is a decimal digit (0-9) or letter (a-z or A-Z).
 	% Returns the character's value as a digit (0-9 or 10-35).
+:- pred char__digit_to_int(char::in, int::out) is semidet.
 
-:- pred char__int_to_digit(int, char).
-:- mode char__int_to_digit(in, out) is semidet.
-:- mode char__int_to_digit(out, in) is semidet.
 	% char__int_to_uppercase_digit(Int, DigitChar):
 	% True iff `Int' is an integer in the range 0-35 and
 	% `DigitChar' is a decimal digit or uppercase letter
 	% whose value as a digit is `Int'.
+:- pred char__int_to_digit(int, char).
+:- mode char__int_to_digit(in, out) is semidet.
+:- mode char__int_to_digit(out, in) is semidet.
 
-:- func char__det_int_to_digit(int) = char.
-:- pred char__det_int_to_digit(int, char).
-:- mode char__det_int_to_digit(in, out) is det.
 	% Returns a decimal digit or uppercase letter corresponding to the
 	% value.
 	% Calls error/1 if the integer is not in the range 0-35.
+:- func char__det_int_to_digit(int) = char.
+:- pred char__det_int_to_digit(int::in, char::out) is det.
 
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
@@ -262,27 +245,21 @@
 	char__lower_upper(Lower, _).
 
 char__is_upper(Upper) :-
-	(
-		char__lower_upper(_, Upper)
-	->
+	( char__lower_upper(_, Upper) ->
 		true
 	;
 		fail
 	).
 
 char__to_lower(Char, Lower) :-
-	(
-		char__lower_upper(LowerChar, Char)
-	->
+	( char__lower_upper(LowerChar, Char) ->
 		Lower = LowerChar
 	;
 		Lower = Char
 	).
 
 char__to_upper(Char, Upper) :-
-	(
-		char__lower_upper(Char, UpperChar)
-	->
+	( char__lower_upper(Char, UpperChar) ->
 		Upper = UpperChar
 	;
 		Upper = Char
@@ -505,6 +482,7 @@
 char__min_char_value(0).
 
 :- pragma foreign_decl("C", "#include <limits.h>").
+
 :- pragma foreign_proc("C",
 	char__max_char_value(Max::out),
 	[will_not_call_mercury, promise_pure, thread_safe],
Index: library/construct.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/construct.m,v
retrieving revision 1.15
diff -u -b -r1.15 construct.m
--- library/construct.m	16 Feb 2004 02:28:03 -0000	1.15
+++ library/construct.m	9 Mar 2004 14:03:31 -0000
@@ -75,8 +75,8 @@
     % functor, or if the types of the arguments do not match
     % the expected argument types of that functor.
     %
-:- func construct(type_desc__type_desc, int, list(univ)) = univ.
-:- mode construct(in, in, in) = out is semidet.
+:- func construct(type_desc__type_desc::in, int::in, list(univ)::in)
+    = (univ::out) is semidet.
 
     % construct_tuple(Args) = Term
     %
@@ -133,8 +133,8 @@
         ** succeed.
         */
     MR_save_transient_registers();
-    success = MR_get_functors_check_range(FunctorNumber,
-                type_info, &construct_info);
+    success = MR_get_functors_check_range(FunctorNumber, type_info,
+        &construct_info);
     MR_restore_transient_registers();
 
         /*
@@ -366,7 +366,6 @@
         ** Build the new term in `new_data'.
         */
     if (success) {
-
         type_ctor_info = MR_TYPEINFO_GET_TYPE_CTOR_INFO(type_info);
 
         if (MR_type_ctor_rep(type_ctor_info) != construct_info.type_ctor_rep) {
@@ -577,9 +576,7 @@
 }").
 
 construct_tuple(Args) =
-    construct_tuple_2(Args,
-        list__map(univ_type, Args),
-        list__length(Args)).
+    construct_tuple_2(Args, list__map(univ_type, Args), list__length(Args)).
 
 :- func construct_tuple_2(list(univ), list(type_desc__type_desc), int) = univ.
 
@@ -614,12 +611,10 @@
 
         size = MR_cell_size(Arity);
         for (i = 0; i < Arity; i++) {
-            arg_data = MR_field(MR_UNIV_TAG, 
-                MR_list_head(Args),
+            arg_data = MR_field(MR_UNIV_TAG, MR_list_head(Args),
                             MR_UNIV_OFFSET_FOR_DATA);
             arg_type_info = (MR_TypeInfo) MR_field(MR_UNIV_TAG, 
-                MR_list_head(Args),
-                MR_UNIV_OFFSET_FOR_TYPEINFO);
+                MR_list_head(Args), MR_UNIV_OFFSET_FOR_TYPEINFO);
                         MR_field(MR_mktag(0), new_data, i) = arg_data;
             size += MR_term_size(arg_type_info, arg_data);
             Args = MR_list_tail(Args);
Index: library/cord.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/cord.m,v
retrieving revision 1.1
diff -u -b -r1.1 cord.m
--- library/cord.m	18 Feb 2003 06:27:32 -0000	1.1
+++ library/cord.m	9 Mar 2004 14:00:58 -0000
@@ -1,11 +1,11 @@
 %---------------------------------------------------------------------------%
-% cord.m
 % vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
 %---------------------------------------------------------------------------%
 % Copyright (C) 2002-2003 The University of Melbourne.
 % This file may only be copied under the terms of the GNU Library General
 % Public License - see the file COPYING.LIB in the Mercury distribution.
 %---------------------------------------------------------------------------%
+%
 % Ralph Becket <rafe at cs.mu.oz.au>
 % Mon Feb  3 12:27:53 EST 2003
 %
@@ -28,8 +28,6 @@
 
 :- import_module list, int.
 
-
-
     % Cords that contain the same members in the same order will not
     % necessarily have the same representation and will, therefore,
     % not necessarily either unify or compare as equal.
@@ -39,8 +37,6 @@
     %
 :- type cord(T).
 
-
-
     % The list of data in a cord:
     %
     %   list(empty        ) = []
@@ -85,8 +81,7 @@
     % An O(n) operation, although traversing an entire cord with
     % head_tail/3 gives O(1) amortized cost for each call.
     %
-:- pred head_tail(cord(T), T,   cord(T)).
-:- mode head_tail(in,      out, out    ) is semidet.
+:- pred head_tail(cord(T)::in, T::out, cord(T)::out) is semidet.
 
     % length(C) = list.length(list(C))
     % An O(n) operation.
@@ -95,8 +90,7 @@
 
     % member(X, C) <=> list.member(X, list(C)).
     %
-:- pred member(T,   cord(T)).
-:- mode member(out, in     ) is nondet.
+:- pred member(T::out, cord(T)::in) is nondet.
 
     % list(map(F, C)) = list.map(F, list(C))
     %
@@ -115,16 +109,13 @@
     %
     % (Note: the current implementation works exactly this way.)
     %
-:- pred equal(cord(T), cord(T)).
-:- mode equal(in,      in     ) is semidet.
+:- pred equal(cord(T)::in, cord(T)::in) is semidet.
 
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
 
 :- implementation.
 
-
-
     % We impose the following invariants to ensure we have a unique
     % representation for the empty cord (this makes the implementation
     % simpler.)
@@ -154,7 +145,6 @@
 %-----------------------------------------------------------------------------%
 
 list(C) = list_2(C, []).
-
 
 :- func list_2(cord(T), list(T)) = list(T).
 
Index: library/deconstruct.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/deconstruct.m,v
retrieving revision 1.26
diff -u -b -r1.26 deconstruct.m
--- library/deconstruct.m	20 Oct 2003 07:29:26 -0000	1.26
+++ library/deconstruct.m	9 Mar 2004 14:37:31 -0000
@@ -46,7 +46,6 @@
 	--->	do_not_allow
 	;	canonicalize.
 
-
 	% functor, argument and deconstruct and their variants take any type
 	% (including univ), and return representation information for that type.
 	%
@@ -246,7 +245,8 @@
 
 :- implementation.
 
-:- import_module int, require, rtti_implementation.
+:- import_module int, string, require, rtti_implementation.
+
 :- pragma foreign_import_module("C", std_util).
 
 %-----------------------------------------------------------------------------%
@@ -256,6 +256,10 @@
 #include ""mercury_deconstruct.h""
 #include ""mercury_deconstruct_macros.h""
 
+extern	MR_Word	MR_make_arg_list(MR_TypeInfo type_info,
+			const MR_DuFunctorDesc *functor_desc,
+			MR_Word *arg_vector);
+
 ").
 
 %-----------------------------------------------------------------------------%
@@ -332,6 +336,7 @@
 	% univ_named_arg_idcc doesn't return an uninitialized
 	% (or otherwise bogus) univ value.
 :- func dummy_univ = univ.
+
 dummy_univ = univ(0).
 
 det_arg(Term, NonCanon, Index, Argument) :-
@@ -372,7 +377,8 @@
 			( Success \= 0 ->
 				Univ = Univ0
 			;
-				error("det_named_arg: no argument with that name")
+				error("det_named_arg: " ++
+					"no argument with that name")
 			)
 		)
 	->
@@ -861,7 +867,6 @@
 	}
 }").
 
-
 deconstruct_dna(Term::in, Functor::out, Arity::out, Arguments::out) :-
 	rtti_implementation__deconstruct(Term,
 			do_not_allow, Functor, Arity, Arguments).
@@ -939,6 +944,7 @@
     MR_unravel_univ(Univ, type_info, value);
     type_ctor_info = MR_TYPEINFO_GET_TYPE_CTOR_INFO(type_info);
     switch (MR_type_ctor_rep(type_ctor_info)) {
+
         case MR_TYPECTOR_REP_NOTAG:
         case MR_TYPECTOR_REP_NOTAG_USEREQ:
             functor_desc = MR_type_ctor_functors(type_ctor_info).
@@ -954,7 +960,8 @@
             functor_desc = MR_type_ctor_functors(type_ctor_info).
 	    	MR_functors_notag;
             exp_type_info = MR_create_type_info(
-                MR_TYPEINFO_GET_FIXED_ARITY_ARG_VECTOR(type_info),
+			MR_TYPEINFO_GET_FIXED_ARITY_ARG_VECTOR(
+				type_info),
                 functor_desc->MR_notag_functor_arg_type);
             MR_new_univ_on_hp(ExpUniv, exp_type_info, value);
             SUCCESS_INDICATOR = MR_TRUE;
@@ -963,6 +970,7 @@
         default:
             SUCCESS_INDICATOR = MR_FALSE;
             break;
+
     }
 }").
 
@@ -984,6 +992,7 @@
     MR_unravel_univ(Univ, type_info, value);
     type_ctor_info = MR_TYPEINFO_GET_TYPE_CTOR_INFO(type_info);
     switch (MR_type_ctor_rep(type_ctor_info)) {
+
         case MR_TYPECTOR_REP_EQUIV:
             exp_type_info = MR_pseudo_type_info_is_ground(
                 MR_type_ctor_layout(type_ctor_info).MR_layout_equiv);
@@ -1002,6 +1011,7 @@
         default:
             SUCCESS_INDICATOR = MR_FALSE;
             break;
+
     }
 }").
 
@@ -1020,6 +1030,7 @@
     MR_unravel_univ(Univ, type_info, value);
     type_ctor_info = MR_TYPEINFO_GET_TYPE_CTOR_INFO(type_info);
     switch (MR_type_ctor_rep(type_ctor_info)) {
+
         case MR_TYPECTOR_REP_ENUM:
         case MR_TYPECTOR_REP_ENUM_USEREQ:
             Enum = (MR_Integer) value;
@@ -1029,16 +1040,18 @@
         default:
             SUCCESS_INDICATOR = MR_FALSE;
             break;
+
     }
 }").
 
-    % Given a value of an arbitrary type, succeed if it is a general du type
-    % (i.e. non-enum, non-notag du type), and return the top function symbol's
-    % arguments as well as its tag information: an indication of where the
-    % secondary tag is (-1 for local secondary tag, 0 for nonexistent secondary
-    % tag, and 1 for remote secondary tag), as well as the primary and
-    % secondary tags themselves (the secondary tag argument will be meaningful
-    % only if the secondary tag exists, of course).
+	% Given a value of an arbitrary type, succeed if it is a general du
+	% type (i.e. non-enum, non-notag du type), and return the top function
+	% symbol's arguments as well as its tag information: an indication of
+	% where the secondary tag is (-1 for local secondary tag, 0 for
+	% nonexistent secondary tag, and 1 for remote secondary tag),
+	% as well as the primary and secondary tags themselves (the secondary
+	% tag argument will be meaningful only if the secondary tag exists,
+	% of course).
 :- pred get_du_functor_info(univ::in, int::out, int::out, int::out,
     list(univ)::out) is semidet.
 
@@ -1057,15 +1070,19 @@
 
     MR_unravel_univ(Univ, type_info, value);
     type_ctor_info = MR_TYPEINFO_GET_TYPE_CTOR_INFO(type_info);
+
     switch (MR_type_ctor_rep(type_ctor_info)) {
+
         case MR_TYPECTOR_REP_DU:
         case MR_TYPECTOR_REP_DU_USEREQ:
+
             SUCCESS_INDICATOR = MR_TRUE;
             Ptag = MR_tag(value);
             ptag_layout = &MR_type_ctor_layout(type_ctor_info).
 	    	MR_layout_du[Ptag];
 
             switch(ptag_layout->MR_sectag_locn) {
+
                 case MR_SECTAG_LOCAL:
                     Where = -1;
                     Sectag = MR_unmkbody(value);
@@ -1085,16 +1102,45 @@
                         arg_vector++;
                     }
 
-                    functor_desc = ptag_layout->MR_sectag_alternatives[Sectag];
+			functor_desc =
+				ptag_layout->MR_sectag_alternatives[Sectag];
                     if (functor_desc->MR_du_functor_exist_info != NULL) {
                         SUCCESS_INDICATOR = MR_FALSE;
                         break;
                     }
 
-                    Args = MR_list_empty_msg(MR_PROC_LABEL);
-                    for (i = functor_desc->MR_du_functor_orig_arity - 1;
-                        i >= 0; i--)
-                    {
+			Args = MR_make_arg_list(type_info, functor_desc,
+				arg_vector);
+			break;
+
+		case MR_SECTAG_VARIABLE:
+			MR_fatal_error(
+				""get_du_functor_info: unexpected variable"");
+
+		default:
+			MR_fatal_error(
+				""get_du_functor_info: unknown sectag locn"");
+		}
+		break;
+
+	default:
+		SUCCESS_INDICATOR = MR_FALSE;
+		break;
+
+	}
+}").
+
+:- pragma foreign_code("C", "
+
+MR_Word
+MR_make_arg_list(MR_TypeInfo type_info, const MR_DuFunctorDesc *functor_desc,
+	MR_Word *arg_vector)
+{
+	int		i;
+	MR_Word		args;
+
+	args = MR_list_empty_msg(MR_PROC_LABEL);
+	for (i = functor_desc->MR_du_functor_orig_arity - 1; i >= 0; i--) {
                         MR_Word         arg;
                         MR_TypeInfo     arg_type_info;
 
@@ -1110,22 +1156,10 @@
                         }
 
                         MR_new_univ_on_hp(arg, arg_type_info, arg_vector[i]);
-                        Args = MR_univ_list_cons_msg(arg, Args, MR_PROC_LABEL);
+		args = MR_univ_list_cons_msg(arg, args, MR_PROC_LABEL);
                     }
-                    break;
-
-                case MR_SECTAG_VARIABLE:
-		    MR_fatal_error(
-		        ""get_du_functor_info: unexpected variable"");
 
-                default:
-                    MR_fatal_error(
-                        ""get_du_functor_info: unknown sectag locn"");
-            }
-            break;
+	return args;
+}
 
-        default:
-            SUCCESS_INDICATOR = MR_FALSE;
-            break;
-    }
-}").
+").
Index: library/hash_table.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/hash_table.m,v
retrieving revision 1.7
diff -u -b -r1.7 hash_table.m
--- library/hash_table.m	20 Mar 2003 22:51:37 -0000	1.7
+++ library/hash_table.m	9 Mar 2004 15:58:47 -0000
@@ -1,10 +1,10 @@
 %-----------------------------------------------------------------------------%
+% vim: ts=4 sw=4 et tw=0 wm=0 ft=mercury
+%-----------------------------------------------------------------------------%
 % Copyright (C) 2001, 2003 The University of Melbourne
 % This file may only be copied under the terms of the GNU Library General
 % Public License - see the file COPYING.LIB in the Mercury distribution.
 %-----------------------------------------------------------------------------%
-% vim: ts=4 sw=4 et tw=0 wm=0 ft=mercury
-%-----------------------------------------------------------------------------%
 %
 % File: hash_table.m
 % Main author: rafe
@@ -41,8 +41,6 @@
 
 :- import_module int, assoc_list, float, string, array, bitmap, char.
 
-
-
 :- type hash_table(K, V).
 
     % XXX This is all fake until the compiler can handle nested unique modes.
@@ -337,37 +335,35 @@
 
 % ---------------------------------------------------------------------------- %
 
-det_insert(HT, K, V) =
-    ( if bitmap__is_set(HT ^ bitmap, H) then
+det_insert(HT0, K, V) = HT :-
+    H = find_slot(HT0, K),
+    ( if bitmap__is_set(HT0 ^ bitmap, H) then
         throw(software_error("hash_table__det_insert: key already present"))
-      else if HT ^ num_occupants = HT ^ max_occupants then
-        set(expand(HT), K, V)
-      else if array__size(HT ^ values) = 0 then
+      else if HT0 ^ num_occupants = HT0 ^ max_occupants then
+        HT = set(expand(HT0), K, V)
+      else if array__size(HT0 ^ values) = 0 then
         % If this is the first entry in the hash table, then we use it to
         % set up the hash table (the arrays are currently empty because we
         % need values to initialise them with).
         %
-        set(HT, K, V)
+        HT = set(HT0, K, V)
       else
-        (((( HT
-                ^ num_occupants    := HT ^ num_occupants + 1 )
-                ^ bitmap           := bitmap__set(HT ^ bitmap, H) )
+        HT = (((( HT0
+                ^ num_occupants    := HT0 ^ num_occupants + 1 )
+                ^ bitmap           := bitmap__set(HT0 ^ bitmap, H) )
                 ^ keys ^ elem(H)   := K )
                 ^ values ^ elem(H) := V )
-    )
- :-
-    H = find_slot(HT, K).
+    ).
 
 % ---------------------------------------------------------------------------- %
 
-det_update(HT, K, V) =
-    ( if bitmap__is_clear(HT ^ bitmap, H) then
+det_update(HT0, K, V) = HT :-
+    H = find_slot(HT0, K),
+    ( if bitmap__is_clear(HT0 ^ bitmap, H) then
         throw(software_error("hash_table__det_update: key not found"))
       else
-        HT ^ values ^ elem(H) := V
-    )
- :-
-    H = find_slot(HT, K).
+        HT = HT0 ^ values ^ elem(H) := V
+    ).
 
 % ---------------------------------------------------------------------------- %
 
@@ -388,8 +384,6 @@
 
 to_assoc_list(HT) = to_assoc_list_2(0, HT, []).
 
-
-
 :- func to_assoc_list_2(int,hash_table(K,V),assoc_list(K,V)) = assoc_list(K,V).
 :- mode to_assoc_list_2(in, hash_table_ui, in) = out is det.
 %:- mode to_assoc_list_2(in, in, in) = out is det.
@@ -532,9 +526,11 @@
 % ---------------------------------------------------------------------------- %
 
 :- func munge_factor_a = int.
+
 munge_factor_a = 5.
 
 :- func munge_factor_b = int.
+
 munge_factor_b = 3.
 
 :- pred double_munge(int, int, int, int, int, int).
@@ -555,8 +551,6 @@
 
 fold(Fn, HT, X) = fold_0(0, Fn, HT, X).
 
-
-
 :- func fold_0(int, func(K, V, T) = T, hash_table(K,V), T) = T.
 :- mode fold_0(in, func(in,in,in) = out is det, hash_table_ui, in) = out is det.
 :- mode fold_0(in, func(in,in,di) = uo is det, hash_table_ui, di) = uo is det.
@@ -580,8 +574,7 @@
     % not a ground type (that is, dynamic_cast/2 will work when the
     % target type is e.g. array(int), but not when it is array(T)).
     %
-:- some [T2] pred dynamic_cast_to_array(T1, array(T2)).
-:-           mode dynamic_cast_to_array(in, out) is semidet.
+:- some [T2] pred dynamic_cast_to_array(T1::in, array(T2)::out) is semidet.
 
 dynamic_cast_to_array(X, A) :-
 
Index: library/integer.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/integer.m,v
retrieving revision 1.14
diff -u -b -r1.14 integer.m
--- library/integer.m	15 Mar 2004 06:50:15 -0000	1.14
+++ library/integer.m	15 Mar 2004 07:11:43 -0000
@@ -27,24 +27,19 @@
 
 :- type integer.
 
-:- pred '<'(integer, integer).
-:- mode '<'(in, in) is semidet.
+:- pred '<'(integer::in, integer::in) is semidet.
 
-:- pred '>'(integer, integer).
-:- mode '>'(in, in) is semidet.
+:- pred '>'(integer::in, integer::in) is semidet.
 
-:- pred '=<'(integer, integer).
-:- mode '=<'(in, in) is semidet.
+:- pred '=<'(integer::in, integer::in) is semidet.
 
-:- pred '>='(integer, integer).
-:- mode '>='(in, in) is semidet.
+:- pred '>='(integer::in, integer::in) is semidet.
 
 :- func integer__integer(int) = integer.
 
 :- func integer__to_string(integer) = string.
 
-:- func integer__from_string(string) = integer.
-:- mode integer__from_string(in) = out is semidet.
+:- func integer__from_string(string::in) = (integer::out) is semidet.
 
 :- func '+'(integer) = integer.
 
@@ -78,8 +73,7 @@
 
 :- func integer__abs(integer) = integer.
 
-:- pred integer__pow(integer, integer, integer).
-:- mode integer__pow(in, in, out) is det.
+:- pred integer__pow(integer::in, integer::in, integer::out) is det.
 :- func integer__pow(integer, integer) = integer.
 
 :- func integer__float(integer) = float.
@@ -314,18 +308,20 @@
 
 big_div(X, Y) = Div :-
 	big_quot_rem(X, Y, Trunc, Rem),
-	( if	integer_signum(Y) * integer_signum(Rem) < 0
-	  then	Div = Trunc - integer__one
-	  else	Div = Trunc
+	( integer_signum(Y) * integer_signum(Rem) < 0 ->
+		Div = Trunc - integer__one
+	;
+		Div = Trunc
 	).
 
 :- func big_mod(integer, integer) = integer.
 
 big_mod(X, Y) = Mod :-
 	big_quot_rem(X, Y, _Trunc, Rem),
-	( if	integer_signum(Y) * integer_signum(Rem) < 0
-	  then	Mod = Rem + Y
-	  else	Mod = Rem
+	( integer_signum(Y) * integer_signum(Rem) < 0 ->
+		Mod = Rem + Y
+	;
+		Mod = Rem
 	).
 
 :- func big_right_shift(integer, int) = integer.
@@ -383,9 +379,10 @@
 	Mod = I mod log2base,
 	NewLen = Len + Div,
 	leftshift(Mod, log2base - Mod, NewLen, Digits, Carry, NewDigits),
-	( if	Carry = 0
-	  then	Integer = i(NewLen, NewDigits)
-	  else	Integer = i(NewLen + 1, [Carry | NewDigits])
+	( Carry = 0 ->
+		Integer = i(NewLen, NewDigits)
+	;
+		Integer = i(NewLen + 1, [Carry | NewDigits])
 	).
 
 :- pred leftshift(int::in, int::in, int::in, list(digit)::in,
@@ -611,7 +608,8 @@
 	;
 		Tail = i(Length, Digits),
 		chop(D, Div, Mod),
-		Result = pos_int_to_digits_2(Div, i(Length + 1, [Mod | Digits]))
+		Result = pos_int_to_digits_2(Div,
+			i(Length + 1, [Mod | Digits]))
 	).
 
 :- func mul_base(integer) = integer.
@@ -711,9 +709,10 @@
 :- func pos_mul(integer, integer) = integer.
 
 pos_mul(i(L1, Ds1), i(L2, Ds2)) =
-	( if	L1 < L2
-	  then	pos_mul_list(Ds1, integer__zero, i(L2, Ds2))
-	  else	pos_mul_list(Ds2, integer__zero, i(L1, Ds1))
+	( L1 < L2 ->
+		pos_mul_list(Ds1, integer__zero, i(L2, Ds2))
+	;
+		pos_mul_list(Ds2, integer__zero, i(L1, Ds1))
 	).
 
 :- func pos_mul_list(list(digit), integer, integer) = integer.
@@ -893,9 +892,10 @@
 	integer__pow(A, N, P).
 
 integer__pow(A, N, P) :-
-	( if	big_isnegative(N)
-	  then	error("integer__pow: negative exponent")
-	  else	P = big_pow(A, N)
+	( big_isnegative(N) ->
+		error("integer__pow: negative exponent")
+	;
+		P = big_pow(A, N)
 	).
 
 :- func big_pow(integer, integer) = integer.
@@ -987,13 +987,14 @@
 :- func string_to_integer(list(char)::in) = (integer::out) is semidet.
 
 string_to_integer(CCs @ [C | Cs]) =
-	( if	C = ('-')
-	  then	big_sign(-1, string_to_integer(Cs))
-	  else	string_to_integer_acc(CCs, integer__zero)
+	( C = ('-') ->
+		big_sign(-1, string_to_integer(Cs))
+	;
+		string_to_integer_acc(CCs, integer__zero)
 	).
 
-:- func string_to_integer_acc(list(char), integer) = integer.
-:- mode string_to_integer_acc(in, in) = out is semidet.
+:- func string_to_integer_acc(list(char)::in, integer::in) = (integer::out)
+	is semidet.
 
 string_to_integer_acc([], Acc) = Acc.
 string_to_integer_acc([C | Cs], Acc) = Result :-
@@ -1048,8 +1049,7 @@
 	[ S ],
 	digits_to_strings(T).
 
-:- pred printbase_rep(integer::in, list(digit)::in, integer::out)
-   is det.
+:- pred printbase_rep(integer::in, list(digit)::in, integer::out) is det.
 
 printbase_rep(Base, Digits, printbase_rep_1(Digits, Base, integer__zero)).
 
@@ -1154,9 +1154,10 @@
 :- func printbase_pos_mul(integer, integer) = integer.
 
 printbase_pos_mul(i(L1, Ds1), i(L2, Ds2)) =
-	( if	L1 < L2
-	  then	printbase_pos_mul_list(Ds1, integer__zero, i(L2, Ds2))
-	  else	printbase_pos_mul_list(Ds2, integer__zero, i(L1, Ds1))
+	( L1 < L2 ->
+		printbase_pos_mul_list(Ds1, integer__zero, i(L2, Ds2))
+	;
+		printbase_pos_mul_list(Ds2, integer__zero, i(L1, Ds1))
 	).
 
 :- func printbase_pos_mul_list(list(digit), integer, integer) = integer.
@@ -1166,6 +1167,4 @@
 	printbase_pos_mul_list(Xs, printbase_pos_plus(mul_base(Carry),
 		printbase_mul_by_digit(X, Y)), Y).
 
-%-----------------------------------------------------------------------------%
-:- end_module integer.
 %-----------------------------------------------------------------------------%
Index: library/list.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/list.m,v
retrieving revision 1.116
diff -u -b -r1.116 list.m
--- library/list.m	31 Oct 2003 03:27:39 -0000	1.116
+++ library/list.m	9 Mar 2004 14:58:00 -0000
@@ -99,15 +99,12 @@
 	% list__remove_suffix(List, Suffix, Prefix):
 	%	The same as list__append(Prefix, Suffix, List) except that
 	%	this is semidet whereas list__append(out, in, in) is nondet.
-:- pred list__remove_suffix(list(T), list(T), list(T)).
-:- mode list__remove_suffix(in, in, out) is semidet.
+:- pred list__remove_suffix(list(T)::in, list(T)::in, list(T)::out) is semidet.
 
 	% list__merge(L1, L2, L):
 	%	L is the result of merging the elements of L1 and L2,
 	%	in ascending order.  L1 and L2 must be sorted.
-:- pred list__merge(list(T), list(T), list(T)).
-:- mode list__merge(in, in, out) is det.
-
+:- pred list__merge(list(T)::in, list(T)::in, list(T)::out) is det.
 :- func list__merge(list(T), list(T)) = list(T).
 
 	% list__merge_and_remove_dups(L1, L2, L):
@@ -115,25 +112,20 @@
 	%	in ascending order, and eliminating any duplicates.
 	%	L1 and L2 must be sorted and must each not contain any
 	%	duplicates.
-:- pred list__merge_and_remove_dups(list(T), list(T), list(T)).
-:- mode list__merge_and_remove_dups(in, in, out) is det.
-
+:- pred list__merge_and_remove_dups(list(T)::in, list(T)::in, list(T)::out)
+	is det.
 :- func list__merge_and_remove_dups(list(T), list(T)) = list(T).
 
 	% list__remove_adjacent_dups(L0, L) :
 	%	L is the result of replacing every sequence of duplicate
 	%	elements in L0 with a single such element.
-:- pred list__remove_adjacent_dups(list(T), list(T)).
-:- mode list__remove_adjacent_dups(in, out) is det.
-
+:- pred list__remove_adjacent_dups(list(T)::in, list(T)::out) is det.
 :- func list__remove_adjacent_dups(list(T)) = list(T).
 
 	% list__remove_dups(L0, L) :
 	%	L is the result of deleting the second and subsequent
 	%	occurrences of every element that occurs twice in L0.
-:- pred list__remove_dups(list(T), list(T)).
-:- mode list__remove_dups(in, out) is det.
-
+:- pred list__remove_dups(list(T)::in, list(T)::out) is det.
 :- func list__remove_dups(list(T)) = list(T).
 
 	% list__member(Elem, List) :
@@ -147,8 +139,7 @@
 	%	a suffix of `List' beginning with `Elem'.
 	%	Same as `SubList = [Elem | _], list__append(_, SubList, List)'.
 	%
-:- pred list__member(T, list(T), list(T)).
-:- mode list__member(out, in, out) is nondet.
+:- pred list__member(T::out, list(T)::in, list(T)::out) is nondet.
 
 	% list__length(List, Length) :
 	%	True iff `Length' is the length of `List', i.e. if
@@ -169,7 +160,7 @@
 :- mode list__same_length(in, output_list_skel) is det.
 :- mode list__same_length(output_list_skel, in) is det.
 :- mode list__same_length(in, in) is semidet.
-	% XXX The current mode checker can't handle these modes
+% XXX The current mode checker can't handle these modes
 % :- mode list__same_length(input_list_skel, output_list_skel) is det.
 % :- mode list__same_length(output_list_skel, input_list_skel) is det.
 
@@ -178,24 +169,21 @@
 	%	and a remainder `End'.
 	%	See also: list__take, list__drop.
 	%
-:- pred list__split_list(int, list(T), list(T), list(T)).
-:- mode list__split_list(in, in, out, out) is semidet.
+:- pred list__split_list(int::in, list(T)::in, list(T)::out, list(T)::out)
+	is semidet.
 
 	% list__take(Len, List, Start):
 	%	`Start' is the first `Len' elements of `List'.
 	%	Fails if `List' has less than `Len' elements.
 	%	See also: list__split_list.
 	%
-:- pred list__take(int, list(T), list(T)).
-:- mode list__take(in, in, out) is semidet.
+:- pred list__take(int::in, list(T)::in, list(T)::out) is semidet.
 
 	% list__take_upto(Len, List, Start):
 	%	`Start' is the first `Len' elements of `List'.
 	%	If `List' has less than `Len' elements, return the entire list.
 	%
-:- pred list__take_upto(int, list(T), list(T)).
-:- mode list__take_upto(in, in, out) is det.
-
+:- pred list__take_upto(int::in, list(T)::in, list(T)::out) is det.
 :- func list__take_upto(int, list(T)) = list(T).
 
 	% list__drop(Len, List, End):
@@ -203,8 +191,7 @@
 	%	first `Len' elements.
 	%	See also: list__split_list.
 	%
-:- pred list__drop(int, list(T), list(T)).
-:- mode list__drop(in, in, out) is semidet.
+:- pred list__drop(int::in, list(T)::in, list(T)::out) is semidet.
 
 	% list__insert(Elem, List0, List):
 	%	`List' is the result of inserting `Elem' somewhere in `List0'.
@@ -232,8 +219,7 @@
 	% list__delete_first(List0, Elem, List) is true iff Elem occurs in List0
 	% and List is List0 with the first occurrence of Elem removed.
 	%
-:- pred list__delete_first(list(T), T, list(T)).
-:- mode list__delete_first(in, in, out) is semidet.
+:- pred list__delete_first(list(T)::in, T::in, list(T)::out) is semidet.
 
 	% list__delete_all(List0, Elem, List) is true iff List is List0 with
 	% all occurrences of Elem removed.
@@ -245,9 +231,7 @@
 	% list__delete_elems(List0, Elems, List) is true iff List is List0 with
 	% all occurrences of all elements of Elems removed.
 	%
-:- pred list__delete_elems(list(T), list(T), list(T)).
-:- mode list__delete_elems(in, in, out) is det.
-
+:- pred list__delete_elems(list(T)::in, list(T)::in, list(T)::out) is det.
 :- func list__delete_elems(list(T), list(T)) = list(T).
 
 	% list__replace(List0, D, R, List) is true iff List is List0
@@ -260,15 +244,13 @@
 	% list__replace_first(List0, D, R, List) is true iff List is List0
 	% with the first occurrence of D replaced with R.
 	%
-:- pred list__replace_first(list(T), T, T, list(T)).
-:- mode list__replace_first(in, in, in, out) is semidet.
+:- pred list__replace_first(list(T)::in, T::in, T::in, list(T)::out)
+	is semidet.
 
 	% list__replace_all(List0, D, R, List) is true iff List is List0
 	% with all occurrences of D replaced with R.
 	%
-:- pred list__replace_all(list(T), T, T, list(T)).
-:- mode list__replace_all(in, in, in, out) is det.
-
+:- pred list__replace_all(list(T)::in, T::in, T::in, list(T)::out) is det.
 :- func list__replace_all(list(T), T, T) = list(T).
 
 	% list__replace_nth(List0, N, R, List) is true iff List is List0
@@ -276,57 +258,48 @@
 	% Fails if N < 1 or if length of List0 < N.
 	% (Position numbers start from 1.)
 	%
-:- pred list__replace_nth(list(T), int, T, list(T)).
-:- mode list__replace_nth(in, in, in, out) is semidet.
+:- pred list__replace_nth(list(T)::in, int::in, T::in, list(T)::out)
+	is semidet.
 
 	% list__replace_nth_det(List0, N, R, List) is true iff List is List0
 	% with Nth element replaced with R.
 	% Aborts if N < 1 or if length of List0 < N.
 	% (Position numbers start from 1.)
 	%
-:- pred list__replace_nth_det(list(T), int, T, list(T)).
-:- mode list__replace_nth_det(in, in, in, out) is det.
-
+:- pred list__replace_nth_det(list(T)::in, int::in, T::in, list(T)::out)
+	is det.
 :- func list__replace_nth_det(list(T), int, T) = list(T).
 
 	% list__sort_and_remove_dups(List0, List):
 	%	List is List0 sorted with the second and subsequent
 	%	occurrence of any duplicates removed.
 	%
-:- pred list__sort_and_remove_dups(list(T), list(T)).
-:- mode list__sort_and_remove_dups(in, out) is det.
-
+:- pred list__sort_and_remove_dups(list(T)::in, list(T)::out) is det.
 :- func list__sort_and_remove_dups(list(T)) = list(T).
 
 	% list__sort(List0, List):
 	%	List is List0 sorted.
 	%
-:- pred list__sort(list(T), list(T)).
-:- mode list__sort(in, out) is det.
-
+:- pred list__sort(list(T)::in, list(T)::out) is det.
 :- func list__sort(list(T)) = list(T).
 
 	% list__reverse(List, Reverse):
 	%	`Reverse' is a list containing the same elements as `List'
 	%	but in reverse order.
 	%
-:- pred list__reverse(list(T), list(T)).
-:- mode list__reverse(in, out) is det.
-
+:- pred list__reverse(list(T)::in, list(T)::out) is det.
 :- func list__reverse(list(T)) = list(T).
 
 	% list__perm(List0, List):
 	%	True iff `List' is a permutation of `List0'.
 	%
-:- pred	list__perm(list(T), list(T)).
-:- mode list__perm(in, out) is nondet.
+:- pred	list__perm(list(T)::in, list(T)::out) is nondet.
 
 	% list__nth_member_search(List, Elem, Position):
 	%	Elem is the Position'th member of List.
 	% 	(Position numbers start from 1.)
 	%
-:- pred list__nth_member_search(list(T), T, int).
-:- mode list__nth_member_search(in, in, out) is semidet.
+:- pred list__nth_member_search(list(T)::in, T::in, int::out) is semidet.
 
 	% list__index*(List, Position, Elem):
 	%	These predicates select an element in a list from it's
@@ -354,26 +327,20 @@
 	%	elements remaining in one of the lists,
 	% 	the remainder of the nonempty list is appended.
 	%
-:- pred list__zip(list(T), list(T), list(T)).
-:- mode list__zip(in, in, out) is det.
-
+:- pred list__zip(list(T)::in, list(T)::in, list(T)::out) is det.
 :- func list__zip(list(T), list(T)) = list(T).
 
 	% list__duplicate(Count, Elem, List) is true iff List is a list
 	% containing Count duplicate copies of Elem.
 	%
-:- pred list__duplicate(int, T, list(T)).
-:- mode list__duplicate(in, in, out) is det.
-
+:- pred list__duplicate(int::in, T::in, list(T)::out) is det.
 :- func list__duplicate(int, T) = list(T).
 
 	% list__condense(ListOfLists, List):
 	%	`List' is the result of concatenating all the
 	%	elements of `ListOfLists'.
 	%
-:- pred list__condense(list(list(T)), list(T)).
-:- mode list__condense(in, out) is det.
-
+:- pred list__condense(list(list(T))::in, list(T)::out) is det.
 :- func list__condense(list(list(T))) = list(T).
 
 	% list__chunk(List, ChunkSize, Chunks):
@@ -384,42 +351,34 @@
 	%	and the length of the last list in `Chunks' is between one
 	%	and `ChunkSize'.)
 	%
-:- pred list__chunk(list(T), int, list(list(T))).
-:- mode list__chunk(in, in, out) is det.
-
+:- pred list__chunk(list(T)::in, int::in, list(list(T))::out) is det.
 :- func list__chunk(list(T), int) = list(list(T)).
 
 	% list__sublist(SubList, FullList) is true
 	%	if one can obtain SubList by starting with FullList
 	%	and deleting some of its elements.
-:- pred list__sublist(list(T), list(T)).
-:- mode list__sublist(in, in) is semidet.
+:- pred list__sublist(list(T)::in, list(T)::in) is semidet.
 
 	% list__all_same(List) is true
 	% 	if all elements of the list are the same
-:- pred list__all_same(list(T)).
-:- mode list__all_same(in) is semidet.
+:- pred list__all_same(list(T)::in) is semidet.
 
 	% list__last(List, Last) is true
 	%	if Last is the last element of List.
-:- pred list__last(list(T), T).
-:- mode list__last(in, out) is semidet.
+:- pred list__last(list(T)::in, T::out) is semidet.
 
 	% A deterministic version of list__last, which aborts instead of
 	% failing if the input list is empty.
-:- pred list__last_det(list(T), T).
-:- mode list__last_det(in, out) is det.
+:- pred list__last_det(list(T)::in, T::out) is det.
 
 	% list__split_last(List, AllButLast, Last) is true
 	%	if Last is the last element of List and AllButLast is the list
 	%	of elements before it.
-:- pred list__split_last(list(T), list(T), T).
-:- mode list__split_last(in, out, out) is semidet.
+:- pred list__split_last(list(T)::in, list(T)::out, T::out) is semidet.
 
 	% A deterministic version of list__split_last, which aborts instead of
 	% failing if the input list is empty.
-:- pred list__split_last_det(list(T), list(T), T).
-:- mode list__split_last_det(in, out, out) is det.
+:- pred list__split_last_det(list(T)::in, list(T)::out, T::out) is det.
 
 %-----------------------------------------------------------------------------%
 %
@@ -474,20 +433,18 @@
 	%
 	% An exception is raised if the list arguments differ in length.
 	%
-:- func list__map_corresponding3(func(A, B, C) = D, list(A), list(B), list(C)) =
-		list(D).
+:- func list__map_corresponding3(func(A, B, C) = D, list(A), list(B), list(C))
+	= list(D).
 
 	% list__filter_map_corresponding/3 is like list__map_corresponding/3
 	% except the function argument is semidet and the output list
 	% consists of only those applications of the function argument that
 	% succeeded.
 	%
-:- func list__filter_map_corresponding(func(A, B) = C,
-		list(A), list(B)
-	) = list(C).
-:- mode list__filter_map_corresponding(func(in, in) = out is semidet,
-		in, in
-	) = out is det.
+:- func list__filter_map_corresponding(func(A, B) = C, list(A), list(B))
+	= list(C).
+:- mode list__filter_map_corresponding(func(in, in) = out is semidet, in, in)
+	= out is det.
 
 	% list__filter_map_corresponding3/4 is like list__map_corresponding3/4
 	% except the function argument is semidet and the output list
@@ -495,11 +452,9 @@
 	% succeeded.
 	%
 :- func list__filter_map_corresponding3(func(A, B, C) = D,
-		list(A), list(B), list(C)
-	) = list(D).
+	list(A), list(B), list(C)) = list(D).
 :- mode list__filter_map_corresponding3(func(in, in, in) = out is semidet,
-		in, in, in
-	) = out is det.
+	in, in, in) = out is det.
 
 	% list__foldl(Pred, List, Start, End) calls Pred with each
 	% element of List (working left-to-right) and an accumulator
@@ -629,25 +584,24 @@
 	% list__filter(Pred, List, TrueList) takes a closure with one
 	% input argument and for each member of List `X', calls the closure.
 	% Iff call(Pred, X) is true, then X is included in TrueList.
-:- pred list__filter(pred(X), list(X), list(X)).
-:- mode list__filter(pred(in) is semidet, in, out) is det.
-
-:- func list__filter(pred(X), list(X)) = list(X).
-:- mode list__filter(pred(in) is semidet, in) = out is det.
+:- pred list__filter(pred(X)::in(pred(in) is semidet), list(X)::in,
+	list(X)::out) is det.
+:- func list__filter(pred(X)::in(pred(in) is semidet), list(X)::in)
+	= (list(X)::out) is det.
 
 	% list__filter(Pred, List, TrueList, FalseList) takes a closure with one
 	% input argument and for each member of List `X', calls the closure.
 	% Iff call(Pred, X) is true, then X is included in TrueList.
 	% Iff call(Pred, X) is false, then X is included in FalseList.
-:- pred list__filter(pred(X), list(X), list(X), list(X)).
-:- mode list__filter(pred(in) is semidet, in, out, out) is det.
+:- pred list__filter(pred(X)::in(pred(in) is semidet), list(X)::in,
+	list(X)::out, list(X)::out) is det.
 
 	% list__filter_map(Transformer, List, TrueList) takes a predicate
 	% with one input argument and one output argument. It is called
 	% with each element of List. If a call succeeds, then the output is
 	% included in TrueList.
-:- pred list__filter_map(pred(X, Y), list(X), list(Y)).
-:- mode list__filter_map(pred(in, out) is semidet, in, out) is det.
+:- pred list__filter_map(pred(X, Y)::in(pred(in, out) is semidet),
+	list(X)::in, list(Y)::out) is det.
 
 :- func list__filter_map(func(X) = Y, list(X)) = list(Y).
 :- mode list__filter_map(func(in) = out is semidet, in) = out is det.
@@ -657,8 +611,8 @@
 	% It is called with each element of List. If a call succeeds,
 	% then the output is included in TrueList; otherwise, the failing
 	% input is included in FalseList.
-:- pred list__filter_map(pred(X, Y), list(X), list(Y), list(X)).
-:- mode list__filter_map(pred(in, out) is semidet, in, out, out) is det.
+:- pred list__filter_map(pred(X, Y)::in(pred(in, out) is semidet),
+	list(X)::in, list(Y)::out, list(X)::out) is det.
 
 	% list__takewhile(Predicate, List, UptoList, AfterList) takes a
 	% closure with one input argument, and calls it on successive members
@@ -666,8 +620,8 @@
 	% the call succeeds are placed in UptoList and the first element for
 	% which the call fails, and all the remaining elements of List are
 	% placed in AfterList.
-:- pred list__takewhile(pred(T), list(T), list(T), list(T)).
-:- mode list__takewhile(pred(in) is semidet, in, out, out) is det.
+:- pred list__takewhile(pred(T)::in(pred(in) is semidet), list(T)::in,
+	list(T)::out, list(T)::out) is det.
 
 %-----------------------------------------------------------------------------%
 
@@ -677,9 +631,8 @@
 	% term Compare, and the elements that are equivalent in this ordering
 	% appear in the same sequence in Sorted as they do in Unsorted
 	% (that is, the sort is stable).
-:- pred list__sort(comparison_pred(X), list(X), list(X)).
-:- mode list__sort(in(comparison_pred), in, out) is det.
-
+:- pred list__sort(comparison_pred(X)::in(comparison_pred), list(X)::in,
+	list(X)::out) is det.
 :- func list__sort(comparison_func(X), list(X)) = list(X).
 
 	% list__sort_and_remove_dups(Compare, Unsorted, Sorted) is true iff
@@ -688,15 +641,15 @@
 	% predicate term Compare, except that if two elements in Unsorted
 	% are equivalent with respect to this ordering only the one which
 	% occurs first will be in Sorted.
-:- pred list__sort_and_remove_dups(comparison_pred(X), list(X), list(X)).
-:- mode list__sort_and_remove_dups(in(comparison_pred), in, out) is det.
+:- pred list__sort_and_remove_dups(comparison_pred(X)::in(comparison_pred),
+	list(X)::in, list(X)::out) is det.
 
 	% list__remove_adjacent_dups(P, L0, L) is true iff L is the result
 	% of replacing every sequence of elements in L0 which are equivalent
 	% with respect to the ordering, with the first occurrence in L0 of
 	% such an element.
-:- pred list__remove_adjacent_dups(comparison_pred(X), list(X), list(X)).
-:- mode list__remove_adjacent_dups(in(comparison_pred), in, out) is det.
+:- pred list__remove_adjacent_dups(comparison_pred(X)::in(comparison_pred),
+	list(X)::in, list(X)::out) is det.
 
 	% list__merge(Compare, As, Bs, Sorted) is true iff, assuming As and
 	% Bs are sorted with respect to the ordering defined by Compare,
@@ -705,8 +658,8 @@
 	% if they come from the same list then they appear in the same
 	% sequence in Sorted as they do in that list, otherwise the elements
 	% from As appear before the elements from Bs.
-:- pred list__merge(comparison_pred(X), list(X), list(X), list(X)).
-:- mode list__merge(in(comparison_pred), in, in, out) is det.
+:- pred list__merge(comparison_pred(X)::in(comparison_pred),
+	list(X)::in, list(X)::in, list(X)::out) is det.
 
 :- func list__merge(comparison_func(X), list(X), list(X)) = list(X).
 
@@ -717,9 +670,8 @@
 	% contains no duplicates.  If an element from As is duplicated in
 	% Bs (that is, they are equivalent in the ordering), then the element
 	% from As is the one that appears in Sorted.
-:- pred list__merge_and_remove_dups(comparison_pred(X), list(X), list(X),
-	list(X)).
-:- mode list__merge_and_remove_dups(in(comparison_pred), in, in, out) is det.
+:- pred list__merge_and_remove_dups(comparison_pred(X)::in(comparison_pred),
+	list(X)::in, list(X)::in, list(X)::out) is det.
 
 :- func list__merge_and_remove_dups(comparison_func(X), list(X), list(X))
 	= list(X).
@@ -786,7 +738,7 @@
 
 :- implementation.
 
-:- import_module bintree_set, require, std_util.
+:- import_module string, bintree_set, require, std_util.
 
 %-----------------------------------------------------------------------------%
 
@@ -915,19 +867,21 @@
 
 list__replace_nth_det(Xs, P, R, L) :-
 	( P > 0 ->
-		(
-			list__replace_nth_2(Xs, P, R, L0)
-		->
+		( list__replace_nth_2(Xs, P, R, L0) ->
 			L = L0
 		;
-			error("list__replace_nth_det: Can't replace element whose index position is past the end of the list")
+			error("list__replace_nth_det: " ++
+				"Can't replace element whose index " ++
+				"position is past the end of the list")
 		)
 	;
-		error("list__replace_nth_det: Can't replace element whose index position is less than 1.")
+		error("list__replace_nth_det: " ++
+			"Can't replace element whose index " ++
+			"position is less than 1.")
 	).
 
-:- pred list__replace_nth_2(list(T), int, T, list(T)).
-:- mode list__replace_nth_2(in, in, in, out) is semidet.
+:- pred list__replace_nth_2(list(T)::in, int::in, T::in, list(T)::out)
+	is semidet.
 
 list__replace_nth_2([X | Xs], P, R, L) :-
 	( P = 1 ->
@@ -1015,8 +969,7 @@
 list__reverse(L0, L) :-
 	list__reverse_2(L0, [], L).
 
-:- pred list__reverse_2(list(T), list(T), list(T)).
-:- mode list__reverse_2(in, in, out) is det.
+:- pred list__reverse_2(list(T)::in, list(T)::in, list(T)::out) is det.
 
 list__reverse_2([], L, L).
 list__reverse_2([X | Xs], L0, L) :-
@@ -1033,15 +986,15 @@
 
 %-----------------------------------------------------------------------------%
 
-:- pred list__merge_sort(list(T), list(T)).
-:- mode list__merge_sort(in, out) is det.
+:- pred list__merge_sort(list(T)::in, list(T)::out) is det.
+
 :- pragma type_spec(list__merge_sort(in, out), T = var(_)).
 
 list__merge_sort(List, SortedList) :-
 	list__merge_sort_2(list__length(List), List, SortedList).
 
-:- pred list__merge_sort_2(int, list(T), list(T)).
-:- mode list__merge_sort_2(in, in, out) is det.
+:- pred list__merge_sort_2(int::in, list(T)::in, list(T)::out) is det.
+
 :- pragma type_spec(list__merge_sort_2(in, in, out), T = var(_)).
 
 list__merge_sort_2(Length, List, SortedList) :-
@@ -1065,8 +1018,8 @@
 	bintree_set__init(Zs0),
 	list__remove_dups_2(Xs, Zs0, Ys).
 
-:- pred list__remove_dups_2(list(T), bintree_set(T), list(T)).
-:- mode list__remove_dups_2(in, in, out) is det.
+:- pred list__remove_dups_2(list(T)::in, bintree_set(T)::in, list(T)::out)
+	is det.
 
 list__remove_dups_2([], _SoFar, []).
 list__remove_dups_2([X | Xs], SoFar0, Zs) :-
@@ -1086,10 +1039,10 @@
 list__remove_adjacent_dups([X | Xs], L) :-
 	list__remove_adjacent_dups_2(Xs, X, L).
 
-:- pred list__remove_adjacent_dups_2(list(T), T, list(T)).
-:- mode list__remove_adjacent_dups_2(in, in, out) is det.
+:- pred list__remove_adjacent_dups_2(list(T)::in, T::in, list(T)::out) is det.
 :- pragma type_spec(list__remove_adjacent_dups_2/3, T = var(_)).
 
+
 list__remove_adjacent_dups_2([], X, [X]).
 list__remove_adjacent_dups_2([X1 | Xs], X0, L) :-
 	( X0 = X1 ->
@@ -1114,25 +1067,6 @@
 
 %-----------------------------------------------------------------------------%
 
-/**** unused
-:- pred list__split3(list(T), list(T), list(T), list(T)).
-:- mode list__split3(in, out, in, in) is semidet.
-
-list__split3(As, Bs, Cs, Ds) :-
-	list__length(As, AL),
-	list__length(Cs, CL),
-	list__length(Ds, DL),
-	N1 = AL + CL,
-	BL = DL - N1,
-	N2 = AL + BL,
-	list__take(AL, Ds, As),
-	list__drop(N2, Ds, Cs),
-	list__drop(AL, Ds, Ts),
-	list__take(BL, Ts, Bs).
-*****/
-
-%-----------------------------------------------------------------------------%
-
 list__split_list(N, List, Start, End) :-
 	( N = 0 ->
 		Start = [],
@@ -1187,8 +1121,8 @@
 list__chunk(List, ChunkSize, ListOfSmallLists) :-
 	list__chunk_2(List, ChunkSize, [], ChunkSize, ListOfSmallLists).
 
-:- pred list__chunk_2(list(T), int, list(T), int, list(list(T))).
-:- mode list__chunk_2(in, in, in, in, out) is det.
+:- pred list__chunk_2(list(T)::in, int::in, list(T)::in, int::in,
+	list(list(T))::out) is det.
 
 list__chunk_2([], _ChunkSize, List0, _N, Lists) :-
 	( List0 = [] ->
@@ -1230,8 +1164,7 @@
 list__all_same([H | T]) :-
 	list__all_same_2(H, T).
 
-:- pred list__all_same_2(T, list(T)).
-:- mode list__all_same_2(in, in) is semidet.
+:- pred list__all_same_2(T::in, list(T)::in) is semidet.
 
 list__all_same_2(_, []).
 list__all_same_2(H, [H | T]) :-
@@ -1291,59 +1224,66 @@
 	call(P, H0, H1, H2, H3),
 	list__map3(P, T0, T1, T2, T3).
 
-list__map_corresponding(_, [],       []      ) = [].
-
-list__map_corresponding(_, [],       [_ | _] ) =
+list__map_corresponding(_, [], []) = [].
+list__map_corresponding(_, [], [_ | _]) =
 	func_error("list__map_corresponding/3: mismatched list arguments").
-
-list__map_corresponding(_, [_ | _],  []      ) =
+list__map_corresponding(_, [_ | _], []) =
 	func_error("list__map_corresponding/3: mismatched list arguments").
-
 list__map_corresponding(F, [A | As], [B | Bs]) =
 	[F(A, B) | list__map_corresponding(F, As, Bs)].
 
 list__map_corresponding3(F, As, Bs, Cs) =
-
-	( if      As = [A | As0], Bs = [B | Bs0], Cs = [C | Cs0]
-	  then    [F(A, B, C) | list__map_corresponding3(F, As0, Bs0, Cs0)]
-
-	  else if As = [],        Bs = [],        Cs = []
-	  then    []
-
-	  else    func_error("list__map_corresponding3: \
-mismatched list arguments")
+	(
+		As = [A | As0],
+		Bs = [B | Bs0],
+		Cs = [C | Cs0]
+	->
+		[F(A, B, C) | list__map_corresponding3(F, As0, Bs0, Cs0)]
+	;
+		As = [],
+		Bs = [],
+		Cs = []
+	->
+		[]
+	;
+		func_error("list__map_corresponding3: " ++
+			"mismatched list arguments")
 	).
 
-list__filter_map_corresponding(_, [],       []      ) = [].
-
-list__filter_map_corresponding(_, [],       [_ | _] ) =
-	func_error("list__filter_map_corresponding/3: \
-mismatched list arguments").
-
-list__filter_map_corresponding(_, [_ | _],  []      ) =
-	func_error("list__filter_map_corresponding/3: \
-mismatched list arguments").
-
+list__filter_map_corresponding(_, [], []) = [].
+list__filter_map_corresponding(_, [], [_ | _]) =
+	func_error("list__filter_map_corresponding/3: " ++
+		"mismatched list arguments").
+list__filter_map_corresponding(_, [_ | _], []) =
+	func_error("list__filter_map_corresponding/3: " ++
+		"mismatched list arguments").
 list__filter_map_corresponding(F, [A | As], [B | Bs]) =
-	( if   F(A, B) = C
-	  then [C | list__filter_map_corresponding(F, As, Bs)]
-	  else list__filter_map_corresponding(F, As, Bs)
+	( F(A, B) = C ->
+		[C | list__filter_map_corresponding(F, As, Bs)]
+	;
+		list__filter_map_corresponding(F, As, Bs)
 	).
 
 list__filter_map_corresponding3(F, As, Bs, Cs) =
-
-	( if      As = [A | As0], Bs = [B | Bs0], Cs = [C | Cs0]
-	  then
-	  	  ( if   F(A, B, C) = D
-		    then [D | list__filter_map_corresponding3(F, As0, Bs0, Cs0)]
-		    else list__filter_map_corresponding3(F, As0, Bs0, Cs0)
+	(
+		As = [A | As0],
+		Bs = [B | Bs0],
+		Cs = [C | Cs0]
+	->
+	  	( F(A, B, C) = D ->
+			[D | list__filter_map_corresponding3(F, As0, Bs0, Cs0)]
+		;
+			list__filter_map_corresponding3(F, As0, Bs0, Cs0)
 		  )
-
-	  else if As = [],        Bs = [],        Cs = []
-	  then    []
-
-	  else    func_error("list__filter_map_corresponding3: \
-mismatched list arguments")
+	;
+		As = [],
+		Bs = [],
+		Cs = []
+	->
+		[]
+	;
+		func_error("list__filter_map_corresponding3: " ++
+			"mismatched list arguments")
 	).
 
 list__foldl(_, [], !A).
@@ -1443,8 +1383,8 @@
 list__remove_adjacent_dups(P, [X | Xs], L) :-
 	list__remove_adjacent_dups_2(P, Xs, X, L).
 
-:- pred list__remove_adjacent_dups_2(comparison_pred(T), list(T), T, list(T)).
-:- mode list__remove_adjacent_dups_2(in(comparison_pred), in, in, out) is det.
+:- pred list__remove_adjacent_dups_2(comparison_pred(T)::in(comparison_pred),
+	list(T)::in, T::in, list(T)::out) is det.
 
 list__remove_adjacent_dups_2(_, [], X, [X]).
 list__remove_adjacent_dups_2(P, [X1 | Xs], X0, L) :-
@@ -1457,21 +1397,17 @@
 
 list__sort(P, L0, L) :-
 	list__length(L0, N),
-	(
-		N = 0
-	->
+	( N = 0 ->
 		L = []
-	;
-		list__hosort(P, N, L0, L1, [])
-	->
+	; list__hosort(P, N, L0, L1, []) ->
 		L = L1
 	;
 		error("hosort failed")
 	).
 
 % list__hosort is actually det but the compiler can't confirm it
-:- pred list__hosort(comparison_pred(X), int, list(X), list(X), list(X)).
-:- mode list__hosort(in(comparison_pred), in, in, out, out) is semidet.
+:- pred list__hosort(comparison_pred(X)::in(comparison_pred), int::in,
+	list(X)::in, list(X)::out, list(X)::out) is semidet.
 
 	% list__hosort is a Mercury implementation of the mergesort
 	% described in The Craft of Prolog.
@@ -1481,14 +1417,10 @@
 	% length implicit in the list itself), we get a semidet unification
 	% when we deconstruct the list.
 list__hosort(P, N, L0, L, Rest) :-
-	(
-		N = 1
-	->
+	( N = 1 ->
 		L0 = [X | Rest],
 		L = [X]
-	;
-		N = 2
-	->
+	; N = 2 ->
 		L0 = [X, Y | Rest],
 		call(P, X, Y, C),
 		(
@@ -1551,10 +1483,12 @@
 %
 :- func empty_list = list(T).
 :- pragma export(empty_list = out, "ML_empty_list").
+
 empty_list = [].
 
 :- func cons(T, list(T)) = list(T).
 :- pragma export((cons(in, in) = (out)), "ML_cons").
+
 cons(H, T) = [H | T].
 
 %-----------------------------------------------------------------------------%
@@ -1562,10 +1496,12 @@
 % Ralph Becket <rwab1 at cam.sri.com> 27/04/99
 %       Function forms added.
 
-list__det_head([]) = _ :- error("list__det_head/1: empty list as argument").
+list__det_head([]) = _ :-
+	error("list__det_head/1: empty list as argument").
 list__det_head([X | _]) = X.
 
-list__det_tail([]) = _ :- error("list__det_tail/1: empty list as argument").
+list__det_tail([]) = _ :-
+	error("list__det_tail/1: empty list as argument").
 list__det_tail([_ | Xs]) = Xs.
 
 list__append(Xs, Ys) = Zs :-
@@ -1666,9 +1602,9 @@
 % ---------------------------------------------------------------------------- %
 
 list__series(I, OK, Succ) =
-	( if OK(I) then
+	( OK(I) ->
 		[I | list__series(Succ(I), OK, Succ)]
-	  else
+	;
 	  	[]
 	).
 
Index: library/math.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/math.m,v
retrieving revision 1.47
diff -u -b -r1.47 math.m
--- library/math.m	11 Dec 2003 03:05:39 -0000	1.47
+++ library/math.m	9 Mar 2004 15:27:07 -0000
@@ -45,11 +45,9 @@
 
 	% Pythagoras' number
 :- func math__pi = float.
-:- mode math__pi = out is det.
 
 	% Base of natural logarithms
 :- func math__e = float.
-:- mode math__e = out is det.
 
 %---------------------------------------------------------------------------%
 % "Next integer" operations
@@ -57,23 +55,19 @@
 	% math__ceiling(X) = Ceil is true if Ceil is the smallest integer
 	% not less than X.
 :- func math__ceiling(float) = float.
-:- mode math__ceiling(in) = out is det.
 
 	% math__floor(X) = Floor is true if Floor is the largest integer
 	% not greater than X.
 :- func math__floor(float) = float.
-:- mode math__floor(in) = out is det.
 
 	% math__round(X) = Round is true if Round is the integer
 	% closest to X.  If X has a fractional value of 0.5, it
 	% is rounded up.
 :- func math__round(float) = float.
-:- mode math__round(in) = out is det.
 
 	% math__truncate(X) = Trunc is true if Trunc is the integer
 	% closest to X such that |Trunc| =< |X|.
 :- func math__truncate(float) = float.
-:- mode math__truncate(in) = out is det.
 
 %---------------------------------------------------------------------------%
 % Polynomial roots
@@ -83,7 +77,6 @@
 	%
 	% Domain restriction: X >= 0
 :- func math__sqrt(float) = float.
-:- mode math__sqrt(in) = out is det.
 
 :- type math__quadratic_roots
 	--->	no_roots
@@ -95,7 +88,6 @@
 	%
 	% Domain restriction: A \= 0
 :- func math__solve_quadratic(float, float, float) = quadratic_roots.
-:- mode math__solve_quadratic(in, in, in) = out is det.
 
 %---------------------------------------------------------------------------%
 % Power/logarithm operations
@@ -105,79 +97,66 @@
 	%
 	% Domain restriction: X >= 0 and (X = 0 implies Y > 0)
 :- func math__pow(float, float) = float.
-:- mode math__pow(in, in) = out is det.
 
 	% math__exp(X) = Exp is true if Exp is e raised to the
 	% power of X.
 :- func math__exp(float) = float.
-:- mode math__exp(in) = out is det.
 
 	% math__ln(X) = Log is true if Log is the natural logarithm
 	% of X.
 	%
 	% Domain restriction: X > 0
 :- func math__ln(float) = float.
-:- mode math__ln(in) = out is det.
 
 	% math__log10(X) = Log is true if Log is the logarithm to
 	% base 10 of X.
 	%
 	% Domain restriction: X > 0
 :- func math__log10(float) = float.
-:- mode math__log10(in) = out is det.
 
 	% math__log2(X) = Log is true if Log is the logarithm to
 	% base 2 of X.
 	%
 	% Domain restriction: X > 0
 :- func math__log2(float) = float.
-:- mode math__log2(in) = out is det.
 
 	% math__log(B, X) = Log is true if Log is the logarithm to
 	% base B of X.
 	%
 	% Domain restriction: X > 0 and B > 0 and B \= 1
 :- func math__log(float, float) = float.
-:- mode math__log(in, in) = out is det.
 
 %---------------------------------------------------------------------------%
 % Trigonometric operations
 
 	% math__sin(X) = Sin is true if Sin is the sine of X.
 :- func math__sin(float) = float.
-:- mode math__sin(in) = out is det.
 
 	% math__cos(X) = Cos is true if Cos is the cosine of X.
 :- func math__cos(float) = float.
-:- mode math__cos(in) = out is det.
 
 	% math__tan(X) = Tan is true if Tan is the tangent of X.
 :- func math__tan(float) = float.
-:- mode math__tan(in) = out is det.
 
 	% math__asin(X) = ASin is true if ASin is the inverse
 	% sine of X, where ASin is in the range [-pi/2,pi/2].
 	%
 	% Domain restriction: X must be in the range [-1,1]
 :- func math__asin(float) = float.
-:- mode math__asin(in) = out is det.
 
 	% math__acos(X) = ACos is true if ACos is the inverse
 	% cosine of X, where ACos is in the range [0, pi].
 	%
 	% Domain restriction: X must be in the range [-1,1]
 :- func math__acos(float) = float.
-:- mode math__acos(in) = out is det.
 
 	% math__atan(X) = ATan is true if ATan is the inverse
 	% tangent of X, where ATan is in the range [-pi/2,pi/2].
 :- func math__atan(float) = float.
-:- mode math__atan(in) = out is det.
 
 	% math__atan2(Y, X) = ATan is true if ATan is the inverse
 	% tangent of Y/X, where ATan is in the range [-pi,pi].
 :- func math__atan2(float, float) = float.
-:- mode math__atan2(in, in) = out is det.
 
 %---------------------------------------------------------------------------%
 % Hyperbolic functions
@@ -185,17 +164,14 @@
 	% math__sinh(X) = Sinh is true if Sinh is the hyperbolic
 	% sine of X.
 :- func math__sinh(float) = float.
-:- mode math__sinh(in) = out is det.
 
 	% math__cosh(X) = Cosh is true if Cosh is the hyperbolic
 	% cosine of X.
 :- func math__cosh(float) = float.
-:- mode math__cosh(in) = out is det.
 
 	% math__tanh(X) = Tanh is true if Tanh is the hyperbolic
 	% tangent of X.
 :- func math__tanh(float) = float.
-:- mode math__tanh(in) = out is det.
 
 	% A domain error exception, indicates that the inputs to a function
 	% were outside the domain of the function.  The string indicates
Index: library/multi_map.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/multi_map.m,v
retrieving revision 1.11
diff -u -b -r1.11 multi_map.m
--- library/multi_map.m	1 Dec 2003 01:18:05 -0000	1.11
+++ library/multi_map.m	9 Mar 2004 15:42:31 -0000
@@ -10,7 +10,7 @@
 %
 % This file provides the 'multi_map' ADT.
 % A map (also known as a dictionary or an associative array) is a collection
-% of (Key,Data) pairs which allows you to look up any Data item given the
+% of (Key, Data) pairs which allows you to look up any Data item given the
 % Key.  A multi_map is similar, though allows a one to many relationship
 % between keys and data.
 %
@@ -30,178 +30,158 @@
 %-----------------------------------------------------------------------------%
 
 	% Initialize an empty multi_map.
-:- pred multi_map__init(multi_map(_,_)).
-:- mode multi_map__init(uo) is det.
+:- pred multi_map__init(multi_map(_, _)::uo) is det.
 
 	% Check whether a multi_map is empty.
-:- pred multi_map__is_empty(multi_map(_,_)).
-:- mode multi_map__is_empty(in) is semidet.
+:- pred multi_map__is_empty(multi_map(_, _)::in) is semidet.
 
 	% Check whether multi_map contains key
-:- pred multi_map__contains(multi_map(K,_V), K).
-:- mode multi_map__contains(in, in) is semidet.
+:- pred multi_map__contains(multi_map(K, _V)::in, K::in) is semidet.
 
-:- pred multi_map__member(multi_map(K,V), K, V).
-:- mode multi_map__member(in, out, out) is nondet.
+:- pred multi_map__member(multi_map(K, V)::in, K::out, V::out) is nondet.
 
 	% Search multi_map for given key.
-:- pred multi_map__search(multi_map(K,V), K, list(V)).
-:- mode multi_map__search(in, in, out) is semidet.
+:- pred multi_map__search(multi_map(K, V)::in, K::in, list(V)::out) is semidet.
 
 	% Search multi_map for given key.
-:- pred multi_map__nondet_search(multi_map(K,V), K, V).
-:- mode multi_map__nondet_search(in, in, out) is nondet.
+:- pred multi_map__nondet_search(multi_map(K, V)::in, K::in, V::out) is nondet.
 
 	% Search multi_map for key, but abort if search fails.
-:- pred multi_map__lookup(multi_map(K,V), K, list(V)).
-:- mode multi_map__lookup(in, in, out) is det.
+:- pred multi_map__lookup(multi_map(K, V)::in, K::in, list(V)::out) is det.
 
 	% Search multi_map for key.
-:- pred multi_map__nondet_lookup(multi_map(K,V), K, V).
-:- mode multi_map__nondet_lookup(in, in, out) is nondet.
+:- pred multi_map__nondet_lookup(multi_map(K, V)::in, K::in, V::out) is nondet.
 
 	% Search multi_map for data.
-:- pred multi_map__inverse_search(multi_map(K,V), V, K).
-:- mode multi_map__inverse_search(in, in, out) is nondet.
+:- pred multi_map__inverse_search(multi_map(K, V)::in, V::in, K::out) is nondet.
 
 	% Insert a new key and corresponding value into a multi_map.
 	% Fail if the key already exists.
-:- pred multi_map__insert(multi_map(K,V), K, V, multi_map(K,V)).
-:- mode multi_map__insert(in, in, in, out) is semidet.
+:- pred multi_map__insert(multi_map(K, V)::in, K::in, V::in,
+	multi_map(K, V)::out) is semidet.
 
 	% Insert a new key and corresponding value into a multi_map.
 	% Abort if the key already exists.
-:- pred multi_map__det_insert(multi_map(K,V), K, V, multi_map(K,V)).
-:- mode multi_map__det_insert(in, in, in, out) is det.
+:- pred multi_map__det_insert(multi_map(K, V)::in, K::in, V::in,
+	multi_map(K, V)::out) is det.
 
 	% Update (add) the value corresponding to a given key
 	% Fail if the key doesn't already exist.
-:- pred multi_map__update(multi_map(K,V), K, V, multi_map(K,V)).
-:- mode multi_map__update(in, in, in, out) is semidet.
+:- pred multi_map__update(multi_map(K, V)::in, K::in, V::in,
+	multi_map(K, V)::out) is semidet.
 
 	% Update (add) the value corresponding to a given key
 	% Abort if the key doesn't already exist.
-:- pred multi_map__det_update(multi_map(K,V), K, V, multi_map(K,V)).
-:- mode multi_map__det_update(in, in, in, out) is det.
+:- pred multi_map__det_update(multi_map(K, V)::in, K::in, V::in,
+	multi_map(K, V)::out) is det.
 
 	% Update (replace) the value corresponding to a given key
 	% Abort if the key doesn't already exist.
-:- pred multi_map__det_replace(multi_map(K,V), K, list(V), multi_map(K,V)).
-:- mode multi_map__det_replace(in, in, in, out) is det.
+:- pred multi_map__det_replace(multi_map(K, V)::in, K::in, list(V)::in,
+	multi_map(K, V)::out) is det.
 
 	% Update (add) value if the key is already present, otherwise
 	% insert new key and value.
-:- pred multi_map__set(multi_map(K,V), K, V, multi_map(K,V)).
-:- mode multi_map__set(in, in, in, out) is det.
+:- pred multi_map__set(multi_map(K, V)::in, K::in, V::in, multi_map(K, V)::out)
+	is det.
 
 	% Given a multi_map, return a list of all the keys in the multi_map
-:- pred multi_map__keys(multi_map(K, _V), list(K)).
-:- mode multi_map__keys(in, out) is det.
+:- pred multi_map__keys(multi_map(K, _V)::in, list(K)::out) is det.
 
 	% Given a multi_map, return a list of all the data values in the
 	% multi_map
-:- pred multi_map__values(multi_map(_K, V), list(V)).
-:- mode multi_map__values(in, out) is det.
+:- pred multi_map__values(multi_map(_K, V)::in, list(V)::out) is det.
 
 	% convert a multi_map to an association list
-:- pred multi_map__to_flat_assoc_list(multi_map(K,V), assoc_list(K, V)).
-:- mode multi_map__to_flat_assoc_list(in, out) is det.
+:- pred multi_map__to_flat_assoc_list(multi_map(K, V)::in,
+	assoc_list(K, V)::out) is det.
 
 	% convert an association list to a multi_map
-:- pred multi_map__from_flat_assoc_list(assoc_list(K, V), multi_map(K,V)).
-:- mode multi_map__from_flat_assoc_list(in, out) is det.
+:- pred multi_map__from_flat_assoc_list(assoc_list(K, V)::in,
+	multi_map(K, V)::out) is det.
 
 	% convert a multi_map to an association list, with all the
 	% values for each key in one element of the association list.
-:- pred multi_map__to_assoc_list(multi_map(K, V),
-		assoc_list(K, list(V))).
-:- mode multi_map__to_assoc_list(in, out) is det.
+:- pred multi_map__to_assoc_list(multi_map(K, V)::in,
+	assoc_list(K, list(V))::out) is det.
 
 	% convert an association list with all the values for each
 	% key in one element of the list to a multi_map
-:- pred multi_map__from_assoc_list(assoc_list(K, list(V)),
-		multi_map(K,V)).
-:- mode multi_map__from_assoc_list(in, out) is det.
+:- pred multi_map__from_assoc_list(assoc_list(K, list(V))::in,
+	multi_map(K, V)::out) is det.
 
 	% convert a sorted association list to a multi_map
-:- pred multi_map__from_sorted_assoc_list(assoc_list(K, list(V)), 
-		multi_map(K, V)).
-:- mode multi_map__from_sorted_assoc_list(in, out) is det.
+:- pred multi_map__from_sorted_assoc_list(assoc_list(K, list(V))::in,
+	multi_map(K, V)::out) is det.
 
 	% delete a key and data from a multi_map
 	% if the key is not present, leave the multi_map unchanged
-:- pred multi_map__delete(multi_map(K,V), K, multi_map(K,V)).
-:- mode multi_map__delete(in, in, out) is det.
+:- pred multi_map__delete(multi_map(K, V)::in, K::in, multi_map(K, V)::out)
+	is det.
 
 	% delete a data value from a key in a multi_map
 	% if the key is not present, leave the multi_map unchanged
-:- pred multi_map__delete(multi_map(K,V), K, V, multi_map(K,V)).
-:- mode multi_map__delete(in, in, in, out) is det.
+:- pred multi_map__delete(multi_map(K, V)::in, K::in, V::in,
+	multi_map(K, V)::out) is det.
 
 	% delete a key-value pair from a multi_map and return the value.
 	% fail if the key is not present
-:- pred multi_map__remove(multi_map(K,V), K, list(V), multi_map(K,V)).
-:- mode multi_map__remove(in, in, out, out) is semidet.
+:- pred multi_map__remove(multi_map(K, V)::in, K::in, list(V)::out,
+	multi_map(K, V)::out) is semidet.
 
 	% delete a key-value pair from a multi_map and return the value.
 	% abort if the key is not present
-:- pred multi_map__det_remove(multi_map(K,V), K, list(V), multi_map(K,V)).
-:- mode multi_map__det_remove(in, in, out, out) is det.
+:- pred multi_map__det_remove(multi_map(K, V)::in, K::in, list(V)::out,
+	multi_map(K, V)::out) is det.
 
 	% Count the number of elements (keys) in the multi_map.
-:- pred multi_map__count(multi_map(K, V), int).
-:- mode multi_map__count(in, out) is det.
+:- pred multi_map__count(multi_map(K, V)::in, int::out) is det.
 
 	% Count the number of data elements in the multi_map.
-:- pred multi_map__all_count(multi_map(K, V), int).
-:- mode multi_map__all_count(in, out) is det.
+:- pred multi_map__all_count(multi_map(K, V)::in, int::out) is det.
 
 	% Convert a pair of lists (which must be of the same length)
 	% to a multi_map.
-:- pred multi_map__from_corresponding_lists(list(K), list(V),
-				multi_map(K, V)).
-:- mode multi_map__from_corresponding_lists(in, in, out) is det.
+:- pred multi_map__from_corresponding_lists(list(K)::in, list(V)::in,
+	multi_map(K, V)::out) is det.
 
 	% Convert a pair of lists (which must be of the same length)
 	% to a multi_map.
-:- pred multi_map__from_corresponding_list_lists(list(K), list(list(V)),
-				multi_map(K, V)).
-:- mode multi_map__from_corresponding_list_lists(in, in, out) is det.
+:- pred multi_map__from_corresponding_list_lists(list(K)::in, list(list(V))::in,
+	multi_map(K, V)::out) is det.
 
 	% For multi_map__merge(MultiMapA, MultiMapB, MultiMap).
-:- pred multi_map__merge(multi_map(K, V), multi_map(K, V), multi_map(K, V)).
-:- mode multi_map__merge(in, in, out) is det.
+:- pred multi_map__merge(multi_map(K, V)::in, multi_map(K, V)::in,
+	multi_map(K, V)::out) is det.
 
 	% multi_map__select takes a multi_map and a set of keys and returns
 	% a multi_map containing the keys in the set and their corresponding
 	% values.
-:- pred multi_map__select(multi_map(K,V), set(K), multi_map(K,V)).
-:- mode multi_map__select(in, in, out) is det.
+:- pred multi_map__select(multi_map(K, V)::in, set(K)::in,
+	multi_map(K, V)::out) is det.
 
 	% Given a list of keys, produce a list of their values in a
 	% specified multi_map.
-:- pred multi_map__apply_to_list(list(K), multi_map(K, V), list(V)).
-:- mode multi_map__apply_to_list(in, in, out) is det.
+:- pred multi_map__apply_to_list(list(K)::in, multi_map(K, V)::in,
+	list(V)::out) is det.
 
 	% Declaratively, a NOP.
 	% Operationally, a suggestion that the implemention
 	% optimize the representation of the multi_map in the expectation
 	% of a number of lookups but few or no modifications.
-:- pred multi_map__optimize(multi_map(K, V), multi_map(K, V)).
-:- mode multi_map__optimize(in, out) is det.
+:- pred multi_map__optimize(multi_map(K, V)::in, multi_map(K, V)::out) is det.
 
 	% Remove the smallest item from the multi_map, fail if 
 	% the multi_map is empty.
-:- pred multi_map__remove_smallest(multi_map(K, V), K, list(V),
-			multi_map(K, V)).
-:- mode multi_map__remove_smallest(in, out, out, out) is semidet.
+:- pred multi_map__remove_smallest(multi_map(K, V)::in, K::out, list(V)::out,
+	multi_map(K, V)::out) is semidet.
 
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
 
 :- implementation.
 
-:- import_module std_util, int, require.
+:- import_module std_util, int, string, require.
 
 %-----------------------------------------------------------------------------%
 
@@ -321,8 +301,7 @@
 	multi_map__values(MultiMap, List),
 	multi_map__count_list(List, 0, Count).
 
-:- pred multi_map__count_list(list(A), int, int).
-:- mode multi_map__count_list(in, in, out) is det.
+:- pred multi_map__count_list(list(A)::in, int::in, int::out) is det.
 
 multi_map__count_list([], X, X).
 multi_map__count_list([_A|As], Count0, Count) :-
@@ -347,17 +326,16 @@
 	->
 		MultiMap = MultiMap1
 	;
-		error("multi_map__from_corresponding_lists: list length mismatch")
+		error("multi_map__from_corresponding_lists: " ++
+			"list length mismatch")
 	).
 
-:- pred multi_map__from_corresponding_lists_2(multi_map(K, V), list(K), list(V),
-	multi_map(K, V)).
-:- mode multi_map__from_corresponding_lists_2(in, in, in, out) is semidet.
+:- pred multi_map__from_corresponding_lists_2(multi_map(K, V)::in, list(K)::in,
+	list(V)::in, multi_map(K, V)::out) is semidet.
 
 multi_map__from_corresponding_lists_2(MultiMap, [], [], MultiMap).
-multi_map__from_corresponding_lists_2(MultiMap0, [Key | Keys], [Value | Values],
-	MultiMap) :-
-
+multi_map__from_corresponding_lists_2(MultiMap0, [Key | Keys],
+		[Value | Values], MultiMap) :-
 	multi_map__set(MultiMap0, Key, Value, MultiMap1),
 	multi_map__from_corresponding_lists_2(MultiMap1, Keys, Values,
 		MultiMap).
@@ -373,9 +351,8 @@
 	multi_map__assoc_list_merge(ML0, ML1, ML),
 	multi_map__from_sorted_assoc_list(ML, M).
 
-:- pred multi_map__assoc_list_merge(assoc_list(K, list(V)), 
-		assoc_list(K, list(V)), assoc_list(K, list(V))).
-:- mode multi_map__assoc_list_merge(in, in, out) is det.
+:- pred multi_map__assoc_list_merge(assoc_list(K, list(V))::in,
+	assoc_list(K, list(V))::in, assoc_list(K, list(V))::out) is det.
 
 multi_map__assoc_list_merge([], ListB, ListB).
 multi_map__assoc_list_merge([A|ListA], [], [A|ListA]).
Index: library/pqueue.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/pqueue.m,v
retrieving revision 1.14
diff -u -b -r1.14 pqueue.m
--- library/pqueue.m	26 May 2003 09:00:30 -0000	1.14
+++ library/pqueue.m	9 Mar 2004 15:07:07 -0000
@@ -29,35 +29,29 @@
 :- type pqueue(_K, _V).
 
 	% Create an empty priority queue
-:- pred pqueue__init(pqueue(_K, _V)).
-:- mode pqueue__init(out) is det.
-
+:- pred pqueue__init(pqueue(_K, _V)::out) is det.
 :- func pqueue__init = pqueue(_K, _V).
 
 	% Insert a value V with key K into a priority queue
 	% and return the new priority queue.
-:- pred pqueue__insert(pqueue(K, V), K, V, pqueue(K, V)).
-:- mode pqueue__insert(in, in, in, out) is det.
-
+:- pred pqueue__insert(pqueue(K, V)::in, K::in, V::in, pqueue(K, V)::out)
+	is det.
 :- func pqueue__insert(pqueue(K, V), K, V) = pqueue(K, V).
 
 	% Remove the smallest item from the priority queue.
-:- pred pqueue__remove(pqueue(K, V), K, V, pqueue(K, V)).
-:- mode pqueue__remove(in, out, out, out) is semidet.
+:- pred pqueue__remove(pqueue(K, V)::in, K::out, V::out, pqueue(K, V)::out)
+	is semidet.
 
 	% Extract all the items from a priority queue by
 	% repeated removal, and place them in an association
 	% list.
-:- pred pqueue__to_assoc_list(pqueue(K, V), assoc_list(K, V)).
-:- mode pqueue__to_assoc_list(in, out) is det.
-
+:- pred pqueue__to_assoc_list(pqueue(K, V)::in, assoc_list(K, V)::out) is det.
 :- func pqueue__to_assoc_list(pqueue(K, V)) = assoc_list(K, V).
 
 	% Insert all the key-value pairs in an association list
 	% into a priority queue.
-:- pred pqueue__assoc_list_to_pqueue(assoc_list(K, V), pqueue(K, V)).
-:- mode pqueue__assoc_list_to_pqueue(in, out) is det.
-
+:- pred pqueue__assoc_list_to_pqueue(assoc_list(K, V)::in, pqueue(K, V)::out)
+	is det.
 :- func pqueue__assoc_list_to_pqueue(assoc_list(K, V)) = pqueue(K, V).
 
 %---------------------------------------------------------------------------%
@@ -66,7 +60,8 @@
 
 :- import_module int, list, std_util.
 
-:- type pqueue(K, V)	--->	empty
+:- type pqueue(K, V)
+	--->	empty
 			;	pqueue(int, K, V, pqueue(K, V), pqueue(K, V)).
 
 %---------------------------------------------------------------------------%
@@ -79,9 +74,7 @@
 pqueue__insert(pqueue(D0, K0, V0, L0, R0), K, V, PQ) :-
 	D = D0 + 1,
 	compare(CMP, K, K0),
-	(
-		CMP = (<)
-	->
+	( CMP = (<) ->
 		K1 = K,
 		V1 = V,
 		pqueue__insert_2(K0, V0, L0, R0, L, R)
@@ -92,9 +85,8 @@
 	),
 	PQ = pqueue(D, K1 ,V1, L, R).
 
-:- pred pqueue__insert_2(K, V, pqueue(K, V), pqueue(K, V),
-						pqueue(K, V), pqueue(K, V)).
-:- mode pqueue__insert_2(in, in, in, in, out, out) is det.
+:- pred pqueue__insert_2(K::in, V::in, pqueue(K, V)::in, pqueue(K, V)::in,
+	pqueue(K, V)::out, pqueue(K, V)::out) is det.
 
 pqueue__insert_2(K, V, empty, empty, pqueue(0, K, V, empty, empty), empty).
 pqueue__insert_2(K, V, pqueue(D0, K0, V0, L0, R0), empty,
@@ -103,9 +95,7 @@
 		pqueue(0, K, V, empty, empty), pqueue(D0, K0, V0, L0, R0)).
 pqueue__insert_2(K, V, pqueue(D0, K0, V0, L0, R0), pqueue(D1, K1, V1, L1, R1),
 								PQ1, PQ2) :-
-	(
-		D0 > D1
-	->
+	( D0 > D1 ->
 		pqueue__insert(pqueue(D1, K1, V1, L1, R1), K, V, PQ2),
 		PQ1 = pqueue(D0, K0, V0, L0, R0)
 	;
@@ -113,23 +103,20 @@
 		PQ2 = pqueue(D1, K1, V1, L1, R1)
 	).
 
-
 %---------------------------------------------------------------------------%
 
 pqueue__remove(pqueue(_, K, V, L0, R0), K, V, PQ) :-
 	pqueue__remove_2(L0, R0, PQ).
 
-:- pred pqueue__remove_2(pqueue(K, V), pqueue(K, V), pqueue(K, V)).
-:- mode pqueue__remove_2(in, in, out) is det.
+:- pred pqueue__remove_2(pqueue(K, V)::in, pqueue(K, V)::in, pqueue(K, V)::out)
+	is det.
 
 pqueue__remove_2(empty, empty, empty).
 pqueue__remove_2(empty, pqueue(D, K, V, L, R), pqueue(D, K, V, L, R)).
 pqueue__remove_2(pqueue(D, K, V, L, R), empty, pqueue(D, K, V, L, R)).
 pqueue__remove_2(pqueue(D0, K0, V0, L0, R0), pqueue(D1, K1, V1, L1, R1), PQ) :-
 	compare(CMP, K0, K1),
-	(
-		CMP = (<)
-	->
+	( CMP = (<) ->
 		D0M1 = D0 - 1,
 		int__max(D0M1, D1, D),
 		pqueue__remove_2(L0, R0, PQ0),
@@ -144,9 +131,7 @@
 %---------------------------------------------------------------------------%
 
 pqueue__to_assoc_list(Q0, L) :-
-	(
-		pqueue__remove(Q0, K, V, Q1)
-	->
+	( pqueue__remove(Q0, K, V, Q1) ->
 		pqueue__to_assoc_list(Q1, L0),
 		L = [K - V | L0]
 	;
@@ -175,4 +160,3 @@
 
 pqueue__assoc_list_to_pqueue(AL) = PQ2 :-
 	pqueue__assoc_list_to_pqueue(AL, PQ2).
-
Index: library/queue.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/queue.m,v
retrieving revision 1.23
diff -u -b -r1.23 queue.m
--- library/queue.m	26 May 2003 09:00:30 -0000	1.23
+++ library/queue.m	9 Mar 2004 15:16:37 -0000
@@ -26,85 +26,68 @@
 
 	% `queue__init(Queue)' is true iff `Queue' is an empty queue.
 
-:- pred queue__init(queue(T)).
-:- mode queue__init(out) is det.
-
+:- pred queue__init(queue(T)::out) is det.
 :- func queue__init = queue(T).
 
 	% 'queue_equal(Q1, Q2)' is true iff Q1 and Q2 contain the same
 	% elements in the same order.
 
-:- pred queue__equal(queue(T), queue(T)).
-:- mode queue__equal(in, in) is semidet.
+:- pred queue__equal(queue(T)::in, queue(T)::in) is semidet.
 
 	% `queue__is_empty(Queue)' is true iff `Queue' is an empty queue.
 
-:- pred queue__is_empty(queue(T)).
-:- mode queue__is_empty(in) is semidet.
+:- pred queue__is_empty(queue(T)::in) is semidet.
 
 	% `queue__is_full(Queue)' is intended to be true iff `Queue'
 	% is a queue whose capacity is exhausted.  This
 	% implementation allows arbitrary-sized queues, so queue__is_full
 	% always fails.
 
-:- pred queue__is_full(queue(T)).
-:- mode queue__is_full(in) is semidet.
+:- pred queue__is_full(queue(T)::in) is semidet.
 
 	% `queue__put(Queue0, Elem, Queue)' is true iff `Queue' is
 	% the queue which results from appending `Elem' onto the end
 	% of `Queue0'.
 
-:- pred queue__put(queue(T), T, queue(T)).
-:- mode queue__put(in, in, out) is det.
-
+:- pred queue__put(queue(T)::in, T::in, queue(T)::out) is det.
 :- func queue__put(queue(T), T) = queue(T).
 
 	% `queue__put_list(Queue0, Elems, Queue)' is true iff `Queue'
 	% is the queue which results from inserting the items in the
 	% list `Elems' into `Queue0'.
 
-:- pred queue__put_list(queue(T), list(T), queue(T)).
-:- mode queue__put_list(in, in, out) is det.
-
+:- pred queue__put_list(queue(T)::in, list(T)::in, queue(T)::out) is det.
 :- func queue__put_list(queue(T), list(T)) = queue(T).
 
 	% `queue__first(Queue, Elem)' is true iff `Queue' is a non-empty
 	% queue whose first element is `Elem'.
 
-:- pred queue__first(queue(T), T).
-:- mode queue__first(in, out) is semidet.
+:- pred queue__first(queue(T)::in, T::out) is semidet.
 
 	% `queue__get(Queue0, Elem, Queue)' is true iff `Queue0' is
 	% a non-empty queue whose first element is `Elem', and `Queue'
 	% the queue which results from removing that element from 
 	% the front of `Queue0'.
 
-:- pred queue__get(queue(T), T, queue(T)).
-:- mode queue__get(in, out, out) is semidet.
+:- pred queue__get(queue(T)::in, T::out, queue(T)::out) is semidet.
 
 	% `queue__length(Queue, Length)' is true iff `Queue' is a queue
 	% containing `Length' elements.
 
-:- pred queue__length(queue(T), int).
-:- mode queue__length(in, out) is det.
-
+:- pred queue__length(queue(T)::in, int::out) is det.
 :- func queue__length(queue(T)) = int.
 
 	% `queue__list_to_queue(List, Queue)' is true iff `Queue' is a queue
 	% containing the elements of List, with the first element of List at
 	% the head of the queue.
 
-:- pred queue__list_to_queue(list(T), queue(T)).
-:- mode queue__list_to_queue(in, out) is det.
-
+:- pred queue__list_to_queue(list(T)::in, queue(T)::out) is det.
 :- func queue__list_to_queue(list(T)) = queue(T).
 
 	% `queue__delete_all(Queue0, Elem, Queue)' is true iff `Queue' is
 	% the same queue as `Queue0' with all occurences of `Elem' removed
 	% from it.
-:- pred queue__delete_all(queue(T), T, queue(T)).
-:- mode queue__delete_all(in, in, out) is det.
-
+:- pred queue__delete_all(queue(T)::in, T::in, queue(T)::out) is det.
 :- func queue__delete_all(queue(T), T) = queue(T).
 
 %--------------------------------------------------------------------------%
@@ -151,8 +134,7 @@
 		queue__put_list_2(Xs, On0, On)
 	).
 
-:- pred queue__put_list_2(list(T), list(T), list(T)).
-:- mode queue__put_list_2(in, in, out) is det.
+:- pred queue__put_list_2(list(T)::in, list(T)::in, list(T)::out) is det.
 
 queue__put_list_2([], On, On).
 queue__put_list_2([X | Xs], On0, On) :-
@@ -209,4 +191,3 @@
 
 queue__delete_all(Q1, T) = Q2 :-
 	queue__delete_all(Q1, T, Q2).
-
Index: library/rbtree.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/rbtree.m,v
retrieving revision 1.15
diff -u -b -r1.15 rbtree.m
--- library/rbtree.m	26 May 2003 09:00:30 -0000	1.15
+++ library/rbtree.m	9 Mar 2004 14:59:56 -0000
@@ -196,7 +196,6 @@
 
 :- import_module bool, int, require, std_util.
 
-
 :- type rbtree(K,V)	 --->	empty
 			;	red(K, V, rbtree(K,V), rbtree(K,V))
 			;	black(K, V, rbtree(K, V), rbtree(K, V)).
@@ -228,7 +227,6 @@
 		Tree = Tree0
 	).
 
-
 :- pred rbtree__insert_2(rbtree(K, V), K, V, rbtree(K, V)). 
 :- mode rbtree__insert_2(in, in, in, out) is semidet.
 
@@ -391,7 +389,6 @@
 		Tree = Tree0
 	).
 
-
 :- pred rbtree__set_2(rbtree(K, V), K, V, rbtree(K, V)). 
 :- mode rbtree__set_2(di, di, di, uo) is det.
 :- mode rbtree__set_2(in, in, in, out) is det.
@@ -522,7 +519,6 @@
 		Tree = Tree0
 	).
 
-
 :- pred rbtree__insert_duplicate_2(rbtree(K, V), K, V, rbtree(K, V)). 
 :- mode rbtree__insert_duplicate_2(in, in, in, out) is det.
 
@@ -933,8 +929,6 @@
 		Tree = black(K0, V0, NewL, R)
 	).
 
-
-
 %-----------------------------------------------------------------------------%
 
 rbtree__keys(empty, []).
@@ -1060,4 +1054,3 @@
 rbtree__map_values(F, T1) = T2 :-
 	P = ( pred(X::in, Y::in, Z::out) is det :- Z = F(X, Y) ),
 	rbtree__map_values(P, T1, T2).
-
Index: library/set.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/set.m,v
retrieving revision 1.62
diff -u -b -r1.62 set.m
--- library/set.m	30 Apr 2003 18:15:51 -0000	1.62
+++ library/set.m	9 Mar 2004 16:37:52 -0000
@@ -23,34 +23,26 @@
 	% `set__list_to_set(List, Set)' is true iff `Set' is the set 
 	% containing only the members of `List'.
 
-:- pred set__list_to_set(list(T), set(T)).
-:- mode set__list_to_set(in, out) is det.
-
+:- pred set__list_to_set(list(T)::in, set(T)::out) is det.
 :- func set__list_to_set(list(T)) = set(T).
 
 	% `set__sorted_list_to_set(List, Set)' is true iff `Set' is the set 
 	% containing only the members of `List'.  `List' must be sorted
 	% and must not contain any duplicates.
 
-:- pred set__sorted_list_to_set(list(T), set(T)).
-:- mode set__sorted_list_to_set(in, out) is det.
-
+:- pred set__sorted_list_to_set(list(T)::in, set(T)::out) is det.
 :- func set__sorted_list_to_set(list(T)) = set(T).
 
 	% `set__to_sorted_list(Set, List)' is true iff `List' is the list
 	% of all the members of `Set', in sorted order without any
 	% duplicates.
 
-:- pred set__to_sorted_list(set(T), list(T)).
-:- mode set__to_sorted_list(in, out) is det.
-
+:- pred set__to_sorted_list(set(T)::in, list(T)::out) is det.
 :- func set__to_sorted_list(set(T)) = list(T).
 
 	% `set__init(Set)' is true iff `Set' is an empty set.
 
-:- pred set__init(set(T)).
-:- mode set__init(uo) is det.
-
+:- pred set__init(set(T)::uo) is det.
 :- func set__init = set(T).
 
 	% `set__singleton_set(Set, Elem)' is true iff `Set' is the set
@@ -65,25 +57,20 @@
 	% `set__equal(SetA, SetB)' is true iff
 	% `SetA' and `SetB' contain the same elements.
 
-:- pred set__equal(set(T), set(T)).
-:- mode set__equal(in, in) is semidet.
+:- pred set__equal(set(T)::in, set(T)::in) is semidet.
 
-:- pred set__empty(set(T)).
-:- mode set__empty(in) is semidet.
+:- pred set__empty(set(T)::in) is semidet.
 
-:- pred set__non_empty(set(T)).
-:- mode set__non_empty(in) is semidet.
+:- pred set__non_empty(set(T)::in) is semidet.
 
 	% `set__subset(SetA, SetB)' is true iff `SetA' is a subset of `SetB'.
 
-:- pred set__subset(set(T), set(T)).
-:- mode set__subset(in, in) is semidet.
+:- pred set__subset(set(T)::in, set(T)::in) is semidet.
 
 	% `set__superset(SetA, SetB)' is true iff `SetA' is a
 	% superset of `SetB'.
 
-:- pred set__superset(set(T), set(T)).
-:- mode set__superset(in, in) is semidet.
+:- pred set__superset(set(T)::in, set(T)::in) is semidet.
 
 	% `set__member(X, Set)' is true iff `X' is a member of `Set'.
 
@@ -94,13 +81,11 @@
 	% `set_is_member(X, Set, Result)' returns
 	% `Result = yes' iff `X' is a member of `Set'.
 
-:- pred set__is_member(T, set(T), bool).
-:- mode set__is_member(in, in, out) is det.
+:- pred set__is_member(T::in, set(T)::in, bool::out) is det.
 
 	% `set__contains(Set, X)' is true iff `X' is a member of `Set'.
 
-:- pred set__contains(set(T), T).
-:- mode set__contains(in, in) is semidet.
+:- pred set__contains(set(T)::in, T::in) is semidet.
 
 	% `set__insert(Set0, X, Set)' is true iff `Set' is the union of
 	% `Set0' and the set containing only `X'.
@@ -116,8 +101,7 @@
 	% `set__insert_list(Set0, Xs, Set)' is true iff `Set' is the union of
 	% `Set0' and the set containing only the members of `Xs'.
 
-:- pred set__insert_list(set(T), list(T), set(T)).
-:- mode set__insert_list(in, in, out) is det.
+:- pred set__insert_list(set(T)::in, list(T)::in, set(T)::out) is det.
 
 	% XXX rwab1: I think we should reverse the args. here for
 	% higher order programming.
@@ -140,8 +124,7 @@
 	% complement of `Set0' and the set containing only the members of
 	% `Xs'.
 
-:- pred set__delete_list(set(T), list(T), set(T)).
-:- mode set__delete_list(in, in, out) is det.
+:- pred set__delete_list(set(T)::in, list(T)::in, set(T)::out) is det.
 
 	% XXX rwab1: I think we should reverse the args. here for
 	% higher order programming.
@@ -152,16 +135,14 @@
 	% containing only `X', i.e.  if `Set' is the set which contains
 	% all the elements of `Set0' except `X'.
 
-:- pred set__remove(set(T), T, set(T)).
-:- mode set__remove(in, in, out) is semidet.
+:- pred set__remove(set(T)::in, T::in, set(T)::out) is semidet.
 
 	% `set__remove_list(Set0, Xs, Set)' is true iff `Xs' does not
 	% contain any duplicates, `Set0' contains every member of `Xs',
 	% and `Set' is the relative complement of `Set0' and the set
 	% containing only the members of `Xs'.
 
-:- pred set__remove_list(set(T), list(T), set(T)).
-:- mode set__remove_list(in, in, out) is semidet.
+:- pred set__remove_list(set(T)::in, list(T)::in, set(T)::out) is semidet.
 
 	% `set__remove_least(Set0, Elem, Set)' is true iff
 	% `Set0' is not empty, `Elem' is the smallest element in `Set0'
@@ -169,8 +150,7 @@
 	% by compare/3), and `Set' is the set containing all the
 	% elements of `Set0' except `Elem'.
 
-:- pred set__remove_least(set(T), T, set(T)).
-:- mode set__remove_least(in, out, out) is semidet.
+:- pred set__remove_least(set(T)::in, T::out, set(T)::out) is semidet.
 
 	% `set_union(SetA, SetB, Set)' is true iff `Set' is the union of
 	% `SetA' and `SetB'.  If the sets are known to be of different
@@ -181,9 +161,7 @@
 	% will make it less likely that you will encounter problems if
 	% the implementation is changed.)
 
-:- pred set__union(set(T), set(T), set(T)).
-:- mode set__union(in, in, out) is det.
-
+:- pred set__union(set(T)::in, set(T)::in, set(T)::out) is det.
 :- func set__union(set(T), set(T)) = set(T).
 
 	% `set__union_list(A, B)' is true iff `B' is the union of
@@ -193,9 +171,7 @@
 	% `set__power_union(A, B)' is true iff `B' is the union of
 	% all the sets in `A'
 
-:- pred set__power_union(set(set(T)), set(T)).
-:- mode set__power_union(in, out) is det.
-
+:- pred set__power_union(set(set(T))::in, set(T)::out) is det.
 :- func set__power_union(set(set(T))) = set(T).
 
 	% `set__intersect(SetA, SetB, Set)' is true iff `Set' is the
@@ -208,17 +184,13 @@
 	% will make it less likely that you will encounter problems if
 	% the implementation is changed.)
 
-:- pred set__intersect(set(T), set(T), set(T)).
-:- mode set__intersect(in, in, out) is det.
-
+:- pred set__intersect(set(T)::in, set(T)::in, set(T)::out) is det.
 :- func set__intersect(set(T), set(T)) = set(T).
 
 	% `set__power_intersect(A, B)' is true iff `B' is the intersection of
 	% all the sets in `A'
 
-:- pred set__power_intersect(set(set(T)), set(T)).
-:- mode set__power_intersect(in, out) is det.
-
+:- pred set__power_intersect(set(set(T))::in, set(T)::out) is det.
 :- func set__power_intersect(set(set(T))) = set(T).
 
 	% `set__intersect_list(A, B)' is true iff `B' is the intersection of
@@ -230,16 +202,12 @@
 	% set containing all the elements of `SetA' except those that
 	% occur in `SetB'
 
-:- pred set__difference(set(T), set(T), set(T)).
-:- mode set__difference(in, in, out) is det.
-
+:- pred set__difference(set(T)::in, set(T)::in, set(T)::out) is det.
 :- func set__difference(set(T), set(T)) = set(T).
 
 	% `set__count(Set, Count)' is true iff `Set' has `Count' elements.
 
-:- pred set__count(set(T), int).
-:- mode set__count(in, out) is det.
-
+:- pred set__count(set(T)::in, int::out) is det.
 :- func set__count(set(T)) = int.
 
--------------------------------------------------------------------------
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