[m-rev.] diff: better support mostly-uniqueness in stdlib

Julien Fischer juliensf at csse.unimelb.edu.au
Wed Jul 30 23:43:56 AEST 2008


Estimated hours taken: 1
Branches: main

Improve support for mostly-uniqueness in the standard library.

library/bimap.m:
library/list.m:
library/map.m:
library/set.m:
library/tree234.m:
 	Add modes to fold style predicates with mostly-unique accumulators.

 	Add semidet versions of fold style predicate with unique accumulators.

 	Re-order the mode declarations for the above predicates; in a lot
 	of cases the ordering made it difficult to see if a required mode
 	was actually present.  The new ordering is by determinism and then
 	by uniqueness.

NEWS:
 	Announce the additions.

Julien.

Index: NEWS
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/NEWS,v
retrieving revision 1.491
diff -u -r1.491 NEWS
--- NEWS	16 Jul 2008 05:06:34 -0000	1.491
+++ NEWS	30 Jul 2008 13:32:09 -0000
@@ -30,6 +30,9 @@

  Changes to the Mercury standard library:

+* We have added extra modes to many of the fold style predicates in the
+  library in order to better support (mostly-)unique accumulators.
+
  * A module for handling directed graphs, digraph.m, has been added.  This
    supersedes relation.m and svrelation.m in that has a more consistent
    interface (which supports state variable notation), provides more type
Index: library/bimap.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/bimap.m,v
retrieving revision 1.28
diff -u -r1.28 bimap.m
--- library/bimap.m	23 Oct 2006 00:32:56 -0000	1.28
+++ library/bimap.m	30 Jul 2008 13:32:09 -0000
@@ -250,8 +250,11 @@
  :- func bimap.foldl(func(K, V, A) = A, bimap(K, V), A) = A.
  :- pred bimap.foldl(pred(K, V, A, A), bimap(K, V), A, A).
  :- mode bimap.foldl(pred(in, in, in, out) is det, in, in, out) is det.
-:- mode bimap.foldl(pred(in, in, in, out) is semidet, in, in, out) is semidet.
+:- mode bimap.foldl(pred(in, in, mdi, muo) is det, in, mdi, muo) is det.
  :- mode bimap.foldl(pred(in, in, di, uo) is det, in, di, uo) is det.
+:- mode bimap.foldl(pred(in, in, in, out) is semidet, in, in, out) is semidet.
+:- mode bimap.foldl(pred(in, in, mdi, muo) is semidet, in, mdi, muo) is semidet.
+:- mode bimap.foldl(pred(in, in, di, uo) is semidet, in, di, uo) is semidet.

      % Perform a traversal of the bimap, applying an accumulator predicate
      % with two accumulators for each key-value pair. (Although no more
Index: library/list.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/list.m,v
retrieving revision 1.172
diff -u -r1.172 list.m
--- library/list.m	16 Jul 2008 03:30:53 -0000	1.172
+++ library/list.m	30 Jul 2008 13:32:09 -0000
@@ -647,8 +647,16 @@
      list(A), list(B), list(C), D, D).
  :- mode list.map_corresponding_foldl(pred(in, in, out, in, out) is det,
      in, in, out, in, out) is det.
+:- mode list.map_corresponding_foldl(pred(in, in, out, mdi, muo) is det,
+    in, in, out, mdi, muo) is det.
  :- mode list.map_corresponding_foldl(pred(in, in, out, di, uo) is det,
      in, in, out, di, uo) is det.
+:- mode list.map_corresponding_foldl(pred(in, in, out, in, out) is semidet,
+    in, in, out, in, out) is semidet.
+:- mode list.map_corresponding_foldl(pred(in, in, out, mdi, muo) is semidet,
+    in, in, out, mdi, muo) is semidet.
+:- mode list.map_corresponding_foldl(pred(in, in, out, di, uo) is semidet,
+    in, in, out, di, uo) is semidet.

      % Like list.map_corresponding_foldl/6 except that it has two
      % accumulators.
@@ -692,10 +700,13 @@
  :- pred list.foldl(pred(L, A, A), list(L), A, A).
  :- mode list.foldl(pred(in, di, uo) is det, in, di, uo) is det.
  :- mode list.foldl(pred(in, in, out) is det, in, in, out) is det.
+:- mode list.foldl(pred(in, mdi, muo) is det, in, mdi, muo) is det.
  :- mode list.foldl(pred(in, in, out) is semidet, in, in, out) is semidet.
  :- mode list.foldl(pred(in, di, uo) is semidet, in, di, uo) is semidet.
+:- mode list.foldl(pred(in, mdi, muo) is semidet, in, mdi, muo) is semidet.
  :- mode list.foldl(pred(in, in, out) is multi, in, in, out) is multi.
  :- mode list.foldl(pred(in, in, out) is nondet, in, in, out) is nondet.
+:- mode list.foldl(pred(in, mdi, muo) is nondet, in, mdi, muo) is nondet.
  :- mode list.foldl(pred(in, di, uo) is cc_multi, in, di, uo) is cc_multi.
  :- mode list.foldl(pred(in, in, out) is cc_multi, in, in, out) is cc_multi.

@@ -707,11 +718,15 @@
      % value in End.
      %
  :- pred list.foldr(pred(L, A, A), list(L), A, A).
-:- mode list.foldr(pred(in, di, uo) is det, in, di, uo) is det.
  :- mode list.foldr(pred(in, in, out) is det, in, in, out) is det.
+:- mode list.foldr(pred(in, mdi, muo) is det, in, mdi, muo) is det.
+:- mode list.foldr(pred(in, di, uo) is det, in, di, uo) is det.
  :- mode list.foldr(pred(in, in, out) is semidet, in, in, out) is semidet.
+:- mode list.foldr(pred(in, mdi, muo) is semidet, in, mdi, muo) is semidet.
+:- mode list.foldr(pred(in, di, uo) is semidet, in, di, uo) is semidet.
  :- mode list.foldr(pred(in, in, out) is multi, in, in, out) is multi.
  :- mode list.foldr(pred(in, in, out) is nondet, in, in, out) is nondet.
+:- mode list.foldr(pred(in, mdi, muo) is nondet, in, mdi, muo) is nondet.
  :- mode list.foldr(pred(in, di, uo) is cc_multi, in, di, uo) is cc_multi.
  :- mode list.foldr(pred(in, in, out) is cc_multi, in, in, out) is cc_multi.

@@ -725,18 +740,22 @@
  :- pred list.foldl2(pred(L, A, A, Z, Z), list(L), A, A, Z, Z).
  :- mode list.foldl2(pred(in, in, out, in, out) is det,
      in, in, out, in, out) is det.
-:- mode list.foldl2(pred(in, in, out, in, out) is cc_multi,
-    in, in, out, in, out) is cc_multi.
-:- mode list.foldl2(pred(in, in, out, in, out) is semidet,
-    in, in, out, in, out) is semidet.
-:- mode list.foldl2(pred(in, in, out, in, out) is nondet,
-    in, in, out, in, out) is nondet.
  :- mode list.foldl2(pred(in, in, out, mdi, muo) is det,
      in, in, out, mdi, muo) is det.
  :- mode list.foldl2(pred(in, in, out, di, uo) is det,
      in, in, out, di, uo) is det.
  :- mode list.foldl2(pred(in, di, uo, di, uo) is det,
      in, di, uo, di, uo) is det.
+:- mode list.foldl2(pred(in, in, out, in, out) is semidet,
+    in, in, out, in, out) is semidet.
+:- mode list.foldl2(pred(in, in, out, mdi, muo) is semidet,
+    in, in, out, mdi, muo) is semidet.
+:- mode list.foldl2(pred(in, in, out, in, out) is nondet,
+    in, in, out, in, out) is nondet.
+:- mode list.foldl2(pred(in, in, out, mdi, muo) is nondet,
+    in, in, out, mdi, muo) is nondet.
+:- mode list.foldl2(pred(in, in, out, in, out) is cc_multi,
+    in, in, out, in, out) is cc_multi.
  :- mode list.foldl2(pred(in, in, out, mdi, muo) is cc_multi,
      in, in, out, mdi, muo) is cc_multi.
  :- mode list.foldl2(pred(in, in, out, di, uo) is cc_multi,
@@ -753,12 +772,18 @@
      A, A, B, B, C, C).
  :- mode list.foldl3(pred(in, in, out, in, out, in, out) is det,
      in, in, out, in, out, in, out) is det.
+:- mode list.foldl3(pred(in, in, out, in, out, mdi, muo) is det,
+    in, in, out, in, out, mdi, muo) is det.
  :- mode list.foldl3(pred(in, in, out, in, out, in, out) is cc_multi,
      in, in, out, in, out, in, out) is cc_multi.
  :- mode list.foldl3(pred(in, in, out, in, out, in, out) is semidet,
      in, in, out, in, out, in, out) is semidet.
+:- mode list.foldl3(pred(in, in, out, in, out, mdi, muo) is semidet,
+    in, in, out, in, out, mdi, muo) is semidet.
  :- mode list.foldl3(pred(in, in, out, in, out, in, out) is nondet,
      in, in, out, in, out, in, out) is nondet.
+:- mode list.foldl3(pred(in, in, out, in, out, mdi, muo) is nondet,
+    in, in, out, in, out, mdi, muo) is nondet.
  :- mode list.foldl3(pred(in, in, out, in, out, di, uo) is det,
      in, in, out, in, out, di, uo) is det.
  :- mode list.foldl3(pred(in, in, out, in, out, di, uo) is cc_multi,
@@ -773,16 +798,22 @@
      A, A, B, B, C, C, D, D).
  :- mode list.foldl4(pred(in, in, out, in, out, in, out, in, out) is det,
      in, in, out, in, out, in, out, in, out) is det.
+:- mode list.foldl4(pred(in, in, out, in, out, in, out, mdi, muo) is det,
+    in, in, out, in, out, in, out, mdi, muo) is det.
+:- mode list.foldl4(pred(in, in, out, in, out, in, out, di, uo) is det,
+    in, in, out, in, out, in, out, di, uo) is det.
  :- mode list.foldl4(pred(in, in, out, in, out, in, out, in, out) is cc_multi,
      in, in, out, in, out, in, out, in, out) is cc_multi.
+:- mode list.foldl4(pred(in, in, out, in, out, in, out, di, uo) is cc_multi,
+    in, in, out, in, out, in, out, di, uo) is cc_multi.
  :- mode list.foldl4(pred(in, in, out, in, out, in, out, in, out) is semidet,
      in, in, out, in, out, in, out, in, out) is semidet.
+:- mode list.foldl4(pred(in, in, out, in, out, in, out, mdi, muo) is semidet,
+    in, in, out, in, out, in, out, mdi, muo) is semidet.
  :- mode list.foldl4(pred(in, in, out, in, out, in, out, in, out) is nondet,
      in, in, out, in, out, in, out, in, out) is nondet.
-:- mode list.foldl4(pred(in, in, out, in, out, in, out, di, uo) is det,
-    in, in, out, in, out, in, out, di, uo) is det.
-:- mode list.foldl4(pred(in, in, out, in, out, in, out, di, uo) is cc_multi,
-    in, in, out, in, out, in, out, di, uo) is cc_multi.
+:- mode list.foldl4(pred(in, in, out, in, out, in, out, mdi, muo) is nondet,
+    in, in, out, in, out, in, out, mdi, muo) is nondet.

      % list.foldl5(Pred, List, !Acc1, !Acc2, !Acc3, !Acc4, !Acc5)
      % Does the same job as list.foldl, but with five accumulators.
@@ -794,18 +825,27 @@
  :- mode list.foldl5(pred(in, in, out, in, out, in, out, in, out, in, out)
      is det,
      in, in, out, in, out, in, out, in, out, in, out) is det.
-:- mode list.foldl5(pred(in, in, out, in, out, in, out, in, out, in, out)
-    is cc_multi,
-    in, in, out, in, out, in, out, in, out, in, out) is cc_multi.
+:- mode list.foldl5(pred(in, in, out, in, out, in, out, in, out, mdi, muo)
+    is det,
+    in, in, out, in, out, in, out, in, out, mdi, muo) is det.
+:- mode list.foldl5(pred(in, in, out, in, out, in, out, in, out, di, uo)
+    is det,
+    in, in, out, in, out, in, out, in, out, di, uo) is det.
  :- mode list.foldl5(pred(in, in, out, in, out, in, out, in, out, in, out)
      is semidet,
      in, in, out, in, out, in, out, in, out, in, out) is semidet.
+:- mode list.foldl5(pred(in, in, out, in, out, in, out, in, out, mdi, muo)
+    is semidet,
+    in, in, out, in, out, in, out, in, out, mdi, muo) is semidet.
  :- mode list.foldl5(pred(in, in, out, in, out, in, out, in, out, in, out)
      is nondet,
      in, in, out, in, out, in, out, in, out, in, out) is nondet.
-:- mode list.foldl5(pred(in, in, out, in, out, in, out, in, out, di, uo)
-    is det,
-    in, in, out, in, out, in, out, in, out, di, uo) is det.
+:- mode list.foldl5(pred(in, in, out, in, out, in, out, in, out, mdi, muo)
+    is nondet,
+    in, in, out, in, out, in, out, in, out, mdi, muo) is nondet.
+:- mode list.foldl5(pred(in, in, out, in, out, in, out, in, out, in, out)
+    is cc_multi,
+    in, in, out, in, out, in, out, in, out, in, out) is cc_multi.
  :- mode list.foldl5(pred(in, in, out, in, out, in, out, in, out, di, uo)
      is cc_multi,
      in, in, out, in, out, in, out, in, out, di, uo) is cc_multi.
@@ -844,14 +884,22 @@
  :- pred list.foldl_corresponding(pred(A, B, C, C), list(A), list(B), C, C).
  :- mode list.foldl_corresponding(pred(in, in, in, out) is det,
      in, in, in, out) is det.
-:- mode list.foldl_corresponding(pred(in, in, in, out) is cc_multi,
-    in, in, in, out) is cc_multi.
+:- mode list.foldl_corresponding(pred(in, in, mdi, muo) is det,
+    in, in, mdi, muo) is det.
+:- mode list.foldl_corresponding(pred(in, in, di, uo) is det,
+    in, in, di, uo) is det.
  :- mode list.foldl_corresponding(pred(in, in, in, out) is semidet,
      in, in, in, out) is semidet.
+:- mode list.foldl_corresponding(pred(in, in, mdi, muo) is semidet,
+    in, in, mdi, muo) is semidet.
+:- mode list.foldl_corresponding(pred(in, in, di, uo) is semidet,
+    in, in, di, uo) is semidet.
  :- mode list.foldl_corresponding(pred(in, in, in, out) is nondet,
      in, in, in, out) is nondet.
-:- mode list.foldl_corresponding(pred(in, in, di, uo) is det,
-    in, in, di, uo) is det.
+:- mode list.foldl_corresponding(pred(in, in, mdi, muo) is nondet,
+    in, in, mdi, muo) is nondet.
+:- mode list.foldl_corresponding(pred(in, in, in, out) is cc_multi,
+    in, in, in, out) is cc_multi.
  :- mode list.foldl_corresponding(pred(in, in, di, uo) is cc_multi,
      in, in, di, uo) is cc_multi.

@@ -863,14 +911,22 @@
      C, C, D, D).
  :- mode list.foldl2_corresponding(pred(in, in, in, out, in, out) is det,
      in, in, in, out, in, out) is det.
-:- mode list.foldl2_corresponding(pred(in, in, in, out, in, out) is cc_multi,
-    in, in, in, out, in, out) is cc_multi.
+:- mode list.foldl2_corresponding(pred(in, in, in, out, mdi, muo) is det,
+    in, in, in, out, mdi, muo) is det.
+:- mode list.foldl2_corresponding(pred(in, in, in, out, di, uo) is det,
+    in, in, in, out, di, uo) is det.
  :- mode list.foldl2_corresponding(pred(in, in, in, out, in, out) is semidet,
      in, in, in, out, in, out) is semidet.
+:- mode list.foldl2_corresponding(pred(in, in, in, out, mdi, muo) is semidet,
+    in, in, in, out, mdi, muo) is semidet.
+:- mode list.foldl2_corresponding(pred(in, in, in, out, di, uo) is semidet,
+    in, in, in, out, di, uo) is semidet.
  :- mode list.foldl2_corresponding(pred(in, in, in, out, in, out) is nondet,
      in, in, in, out, in, out) is nondet.
-:- mode list.foldl2_corresponding(pred(in, in, in, out, di, uo) is det,
-    in, in, in, out, di, uo) is det.
+:- mode list.foldl2_corresponding(pred(in, in, in, out, mdi, muo) is nondet,
+    in, in, in, out, mdi, muo) is nondet.
+:- mode list.foldl2_corresponding(pred(in, in, in, out, in, out) is cc_multi,
+    in, in, in, out, in, out) is cc_multi.
  :- mode list.foldl2_corresponding(pred(in, in, in, out, di, uo) is cc_multi,
      in, in, in, out, di, uo) is cc_multi.

@@ -881,11 +937,23 @@
  :- pred list.foldl3_corresponding(pred(A, B, C, C, D, D, E, E),
      list(A), list(B), C, C, D, D, E, E).
  :- mode list.foldl3_corresponding(
-    pred(in, in, in, out, in, out, in, out) is det, in, in, in, out, in, out,
-    in, out) is det.
+    pred(in, in, in, out, in, out, in, out) is det, in, in, in, out,
+    in, out, in, out) is det.
  :- mode list.foldl3_corresponding(
-    pred(in, in, in, out, in, out, di, uo) is det, in, in, in, out, in, out,
-    di, uo) is det.
+    pred(in, in, in, out, in, out, mdi, muo) is det, in, in, in, out,
+    in, out, mdi, muo) is det.
+:- mode list.foldl3_corresponding(
+    pred(in, in, in, out, in, out, di, uo) is det, in, in, in, out,
+    in, out, di, uo) is det.
+:- mode list.foldl3_corresponding(
+    pred(in, in, in, out, in, out, in, out) is semidet, in, in, in, out,
+    in, out, in, out) is semidet.
+:- mode list.foldl3_corresponding(
+    pred(in, in, in, out, in, out, mdi, muo) is semidet, in, in, in, out,
+    in, out, mdi, muo) is semidet.
+:- mode list.foldl3_corresponding(
+    pred(in, in, in, out, in, out, di, uo) is semidet, in, in, in, out,
+    in, out, di, uo) is semidet.

      % list.foldl_corresponding3(P, As, Bs, Cs, !Acc):
      % Like list.foldl_corresponding but folds over three corresponding
@@ -895,10 +963,16 @@
      list(A), list(B), list(C), D, D).
  :- mode list.foldl_corresponding3(pred(in, in, in, in, out) is det,
      in, in, in, in, out) is det.
+:- mode list.foldl_corresponding3(pred(in, in, in, mdi, muo) is det,
+    in, in, in, mdi, muo) is det.
  :- mode list.foldl_corresponding3(pred(in, in, in, di, uo) is det,
      in, in, in, di, uo) is det.
  :- mode list.foldl_corresponding3(pred(in, in, in, in, out) is semidet,
      in, in, in, in, out) is semidet.
+:- mode list.foldl_corresponding3(pred(in, in, in, mdi, muo) is semidet,
+    in, in, in, mdi, muo) is semidet.
+:- mode list.foldl_corresponding3(pred(in, in, in, di, uo) is semidet,
+    in, in, in, di, uo) is semidet.

      % list.foldl2_corresponding3(P, As, Bs, Cs, !Acc1, !Acc2):
      % like list.foldl_corresponding3 but with two accumulators.
@@ -956,37 +1030,49 @@
      is det.
  :- mode list.map_foldl(pred(in, out, mdi, muo) is det, in, out, mdi, muo)
      is det.
-:- mode list.map_foldl(pred(in, out, di, uo) is cc_multi, in, out, di, uo)
-    is cc_multi.
-:- mode list.map_foldl(pred(in, out, in, out) is cc_multi, in, out, in, out)
-    is cc_multi.
-:- mode list.map_foldl(pred(in, out, mdi, muo) is cc_multi, in, out, mdi, muo)
-    is cc_multi.
  :- mode list.map_foldl(pred(in, out, in, out) is semidet, in, out, in, out)
      is semidet.
+:- mode list.map_foldl(pred(in, out, mdi, muo) is semidet, in, out, mdi, muo)
+    is semidet.
  :- mode list.map_foldl(pred(in, out, di, uo) is semidet, in, out, di, uo)
      is semidet.
  :- mode list.map_foldl(pred(in, in, di, uo) is semidet, in, in, di, uo)
      is semidet.
  :- mode list.map_foldl(pred(in, out, in, out) is nondet, in, out, in, out)
      is nondet.
-
+:- mode list.map_foldl(pred(in, out, mdi, muo) is nondet, in, out, mdi, muo)
+    is nondet.
+:- mode list.map_foldl(pred(in, out, in, out) is cc_multi, in, out, in, out)
+    is cc_multi.
+:- mode list.map_foldl(pred(in, out, mdi, muo) is cc_multi, in, out, mdi, muo)
+    is cc_multi.
+:- mode list.map_foldl(pred(in, out, di, uo) is cc_multi, in, out, di, uo)
+    is cc_multi.
+
      % Same as list.map_foldl, but with two mapped outputs.
      %
  :- pred list.map2_foldl(pred(L, M, N, A, A), list(L), list(M), list(N),
      A, A).
-:- mode list.map2_foldl(pred(in, out, out, di, uo) is det, in, out, out,
-    di, uo) is det.
  :- mode list.map2_foldl(pred(in, out, out, in, out) is det, in, out, out,
      in, out) is det.
-:- mode list.map2_foldl(pred(in, out, out, di, uo) is cc_multi, in, out, out,
-    di, uo) is cc_multi.
-:- mode list.map2_foldl(pred(in, out, out, in, out) is cc_multi, in, out, out,
-    in, out) is cc_multi.
+:- mode list.map2_foldl(pred(in, out, out, mdi, muo) is det, in, out, out,
+    mdi, muo) is det.
+:- mode list.map2_foldl(pred(in, out, out, di, uo) is det, in, out, out,
+    di, uo) is det.
  :- mode list.map2_foldl(pred(in, out, out, in, out) is semidet, in, out, out,
      in, out) is semidet.
+:- mode list.map2_foldl(pred(in, out, out, mdi, muo) is semidet, in, out, out,
+    mdi, muo) is semidet.
+:- mode list.map2_foldl(pred(in, out, out, di, uo) is semidet, in, out, out,
+    di, uo) is semidet.
  :- mode list.map2_foldl(pred(in, out, out, in, out) is nondet, in, out, out,
      in, out) is nondet.
+:- mode list.map2_foldl(pred(in, out, out, mdi, muo) is nondet, in, out, out,
+    mdi, muo) is nondet.
+:- mode list.map2_foldl(pred(in, out, out, in, out) is cc_multi, in, out, out,
+    in, out) is cc_multi.
+:- mode list.map2_foldl(pred(in, out, out, di, uo) is cc_multi, in, out, out,
+    di, uo) is cc_multi.

      % Same as list.map_foldl, but with two accumulators.
      %
Index: library/map.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/map.m,v
retrieving revision 1.111
diff -u -r1.111 map.m
--- library/map.m	21 Jul 2008 03:13:15 -0000	1.111
+++ library/map.m	30 Jul 2008 13:32:09 -0000
@@ -291,14 +291,20 @@
  :- func map.foldl(func(K, V, A) = A, map(K, V), A) = A.
  :- pred map.foldl(pred(K, V, A, A), map(K, V), A, A).
  :- mode map.foldl(pred(in, in, in, out) is det, in, in, out) is det.
-:- mode map.foldl(pred(in, in, in, out) is semidet, in, in, out) is semidet.
+:- mode map.foldl(pred(in, in, mdi, muo) is det, in, mdi, muo) is det.
  :- mode map.foldl(pred(in, in, di, uo) is det, in, di, uo) is det.
+:- mode map.foldl(pred(in, in, in, out) is semidet, in, in, out) is semidet.
+:- mode map.foldl(pred(in, in, mdi, muo) is semidet, in, mdi, muo) is semidet.
+:- mode map.foldl(pred(in, in, di, uo) is semidet, in, di, uo) is semidet.

  :- func map.foldr(func(K, V, A) = A, map(K, V), A) = A.
  :- pred map.foldr(pred(K, V, A, A), map(K, V), A, A).
  :- mode map.foldr(pred(in, in, in, out) is det, in, in, out) is det.
-:- mode map.foldr(pred(in, in, in, out) is semidet, in, in, out) is semidet.
+:- mode map.foldr(pred(in, in, mdi, muo) is det, in, mdi, muo) is det.
  :- mode map.foldr(pred(in, in, di, uo) is det, in, di, uo) is det.
+:- mode map.foldr(pred(in, in, in, out) is semidet, in, in, out) is semidet.
+:- mode map.foldr(pred(in, in, mdi, muo) is semidet, in, mdi, muo) is semidet.
+:- mode map.foldr(pred(in, in, di, uo) is semidet, in, di, uo) is semidet.

      % Perform an inorder traversal of the map, applying an accumulator
      % predicate with two accumulators for each key-value pair.
@@ -308,12 +314,18 @@
  :- pred map.foldl2(pred(K, V, A, A, B, B), map(K, V), A, A, B, B).
  :- mode map.foldl2(pred(in, in, in, out, in, out) is det,
      in, in, out, in, out) is det.
-:- mode map.foldl2(pred(in, in, in, out, in, out) is semidet,
-    in, in, out, in, out) is semidet.
+:- mode map.foldl2(pred(in, in, in, out, mdi, muo) is det,
+    in, in, out, mdi, muo) is det.
  :- mode map.foldl2(pred(in, in, in, out, di, uo) is det,
      in, in, out, di, uo) is det.
  :- mode map.foldl2(pred(in, in, di, uo, di, uo) is det,
      in, di, uo, di, uo) is det.
+:- mode map.foldl2(pred(in, in, in, out, in, out) is semidet,
+    in, in, out, in, out) is semidet.
+:- mode map.foldl2(pred(in, in, in, out, mdi, muo) is semidet,
+    in, in, out, mdi, muo) is semidet.
+:- mode map.foldl2(pred(in, in, in, out, di, uo) is semidet,
+    in, in, out, di, uo) is semidet.

  :- pred map.foldr2(pred(K, V, A, A, B, B), map(K, V), A, A, B, B).
  :- mode map.foldr2(pred(in, in, in, out, in, out) is det,
Index: library/set.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/set.m,v
retrieving revision 1.84
diff -u -r1.84 set.m
--- library/set.m	21 Jul 2008 03:13:16 -0000	1.84
+++ library/set.m	30 Jul 2008 13:32:09 -0000
@@ -263,15 +263,20 @@
  :- func set.fold(func(T, A) = A, set(T), A) = A.

  :- pred set.fold(pred(T, A, A), set(T), A, A).
-:- mode set.fold(pred(in, di, uo) is det, in, di, uo) is det.
  :- mode set.fold(pred(in, in, out) is det, in, in, out) is det.
+:- mode set.fold(pred(in, mdi, muo) is det, in, mdi, muo) is det.
+:- mode set.fold(pred(in, di, uo) is det, in, di, uo) is det.
  :- mode set.fold(pred(in, in, out) is semidet, in, in, out) is semidet.
+:- mode set.fold(pred(in, mdi, muo) is semidet, in, mdi, muo) is semidet.
+:- mode set.fold(pred(in, di, uo) is semidet, in, di, uo) is semidet.

  :- pred set.fold2(pred(T, A, A, B, B), set(T), A, A, B, B).
-:- mode set.fold2(pred(in, in, out, di, uo) is det, in,
-    in, out, di, uo) is det.
  :- mode set.fold2(pred(in, in, out, in, out) is det, in,
      in, out, in, out) is det.
+:- mode set.fold2(pred(in, in, out, mdi, muo) is det, in,
+    in, out, mdi, muo) is det.
+:- mode set.fold2(pred(in, in, out, di, uo) is det, in,
+    in, out, di, uo) is det.
  :- mode set.fold2(pred(in, in, out, in, out) is semidet,
      in, in, out, in, out) is semidet.

Index: library/tree234.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/tree234.m,v
retrieving revision 1.60
diff -u -r1.60 tree234.m
--- library/tree234.m	10 Sep 2007 04:45:07 -0000	1.60
+++ library/tree234.m	30 Jul 2008 13:32:10 -0000
@@ -128,19 +128,30 @@

  :- pred tree234.foldl(pred(K, V, A, A), tree234(K, V), A, A).
  :- mode tree234.foldl(pred(in, in, in, out) is det, in, in, out) is det.
+:- mode tree234.foldl(pred(in, in, mdi, muo) is det, in, mdi, muo) is det.
+:- mode tree234.foldl(pred(in, in, di, uo) is det, in, di, uo) is det.
  :- mode tree234.foldl(pred(in, in, in, out) is semidet, in, in, out)
      is semidet.
-:- mode tree234.foldl(pred(in, in, di, uo) is det, in, di, uo) is det.
+:- mode tree234.foldl(pred(in, in, mdi, muo) is semidet, in, mdi, muo)
+    is semidet.
+:- mode tree234.foldl(pred(in, in, di, uo) is semidet, in, di, uo)
+    is semidet.

  :- pred tree234.foldl2(pred(K, V, A, A, B, B), tree234(K, V), A, A, B, B).
  :- mode tree234.foldl2(pred(in, in, in, out, in, out) is det,
      in, in, out, in, out) is det.
-:- mode tree234.foldl2(pred(in, in, in, out, in, out) is semidet,
-    in, in, out, in, out) is semidet.
+:- mode tree234.foldl2(pred(in, in, in, out, mdi, muo) is det,
+    in, in, out, mdi, muo) is det.
  :- mode tree234.foldl2(pred(in, in, in, out, di, uo) is det,
      in, in, out, di, uo) is det.
  :- mode tree234.foldl2(pred(in, in, di, uo, di, uo) is det,
      in, di, uo, di, uo) is det.
+:- mode tree234.foldl2(pred(in, in, in, out, in, out) is semidet,
+    in, in, out, in, out) is semidet.
+:- mode tree234.foldl2(pred(in, in, in, out, mdi, muo) is semidet,
+    in, in, out, mdi, muo) is semidet.
+:- mode tree234.foldl2(pred(in, in, in, out, di, uo) is semidet,
+    in, in, out, di, uo) is semidet.

  :- pred tree234.foldl3(pred(K, V, A, A, B, B, C, C), tree234(K, V),
  	A, A, B, B, C, C).
@@ -176,9 +187,14 @@

  :- pred tree234.foldr(pred(K, V, A, A), tree234(K, V), A, A).
  :- mode tree234.foldr(pred(in, in, in, out) is det, in, in, out) is det.
+:- mode tree234.foldr(pred(in, in, mdi, muo) is det, in, mdi, muo) is det.
+:- mode tree234.foldr(pred(in, in, di, uo) is det, in, di, uo) is det.
  :- mode tree234.foldr(pred(in, in, in, out) is semidet, in, in, out)
      is semidet.
-:- mode tree234.foldr(pred(in, in, di, uo) is det, in, di, uo) is det.
+:- mode tree234.foldr(pred(in, in, mdi, muo) is semidet, in, mdi, muo)
+    is semidet.
+:- mode tree234.foldr(pred(in, in, di, uo) is semidet, in, di, uo)
+    is semidet.

  :- pred tree234.foldr2(pred(K, V, A, A, B, B), tree234(K, V), A, A, B, B).
  :- mode tree234.foldr2(pred(in, in, in, out, in, out) is det,

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list