[m-rev.] diff: add more modes for list.foldl2, int.fold*

Julien Fischer juliensf at csse.unimelb.edu.au
Sat Dec 13 23:03:56 AEDT 2008


Add some more modes to some standard library predicates.

library/int.m:
 	Add more modes to the int.fold* family of predicates.

 	Re-order the mode declarations as-per the ordering of
 	the higher-order predicates in the list module.

library/list.m:
 	Add another mode of list.foldl2/6.

 	Re-order the mode declarations for list.foldl/4 to conform
 	to the style used for the other fold-style predicates in
 	this module.

Julien.

Index: library/int.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/int.m,v
retrieving revision 1.122
diff -u -r1.122 int.m
--- library/int.m	18 Aug 2008 02:14:59 -0000	1.122
+++ library/int.m	13 Dec 2008 11:59:37 -0000
@@ -242,13 +242,20 @@
      %
  :- pred int.fold_up(pred(int, T, T), int, int, T, T).
  :- mode int.fold_up(pred(in, in, out) is det, in, in, in, out) is det.
+:- mode int.fold_up(pred(in, mdi, muo) is det, in, in, mdi, muo) is det.
  :- mode int.fold_up(pred(in, di, uo) is det, in, in, di, uo) is det.
  :- mode int.fold_up(pred(in, array_di, array_uo) is det, in, in,
      array_di, array_uo) is det.
  :- mode int.fold_up(pred(in, in, out) is semidet, in, in, in, out)
      is semidet.
+:- mode int.fold_up(pred(in, mdi, muo) is semidet, in, in, mdi, muo)
+    is semidet.
+:- mode int.fold_up(pred(in, di, uo) is semidet, in, in, di, uo)
+    is semidet.
  :- mode int.fold_up(pred(in, in, out) is nondet, in, in, in, out)
      is nondet.
+:- mode int.fold_up(pred(in, mdi, muo) is nondet, in, in, mdi, muo) 
+    is nondet.
  :- mode int.fold_up(pred(in, di, uo) is cc_multi, in, in, di, uo)
      is cc_multi.
  :- mode int.fold_up(pred(in, in, out) is cc_multi, in, in, in, out)
@@ -266,17 +273,24 @@
      %
  :- pred int.fold_down(pred(int, T, T), int, int, T, T).
  :- mode int.fold_down(pred(in, in, out) is det, in, in, in, out) is det.
+:- mode int.fold_down(pred(in, mdi, muo) is det, in, in, mdi, muo) is det.
  :- mode int.fold_down(pred(in, di, uo) is det, in, in, di, uo) is det.
  :- mode int.fold_down(pred(in, array_di, array_uo) is det, in, in,
      array_di, array_uo) is det.
  :- mode int.fold_down(pred(in, in, out) is semidet, in, in, in, out)
      is semidet.
+:- mode int.fold_down(pred(in, mdi, muo) is semidet, in, in, mdi, muo)
+    is semidet.
+:- mode int.fold_down(pred(in, di, uo) is semidet, in, in, di, uo)
+    is semidet.
  :- mode int.fold_down(pred(in, in, out) is nondet, in, in, in, out)
      is nondet.
-:- mode int.fold_down(pred(in, di, uo) is cc_multi, in, in, di, uo)
-    is cc_multi.
+:- mode int.fold_down(pred(in, mdi, muo) is nondet, in, in, mdi, muo)
+    is nondet.
  :- mode int.fold_down(pred(in, in, out) is cc_multi, in, in, in, out)
      is cc_multi.
+:- mode int.fold_down(pred(in, di, uo) is cc_multi, in, in, di, uo)
+    is cc_multi.

      % fold_down(F, Low, High, Acc) <=> list.foldr(F, Low .. High, Acc)
      %
@@ -292,14 +306,22 @@
  :- pred int.fold_up2(pred(int, T, T, U, U), int, int, T, T, U, U).
  :- mode int.fold_up2(pred(in, in, out, in, out) is det, in, in, in, out,
      in, out) is det.
-:- mode int.fold_up2(pred(in, in, out, in, out) is semidet, in, in,
-    in, out, in, out) is semidet.
-:- mode int.fold_up2(pred(in, in, out, in, out) is nondet, in, in,
-    in, out, in, out) is nondet.
+:- mode int.fold_up2(pred(in, in, out, mdi, muo) is det, in, in, in, out,
+    mdi, muo) is det.
  :- mode int.fold_up2(pred(in, in, out, di, uo) is det, in, in, in, out,
      di, uo) is det.
  :- mode int.fold_up2(pred(in, di, uo, di, uo) is det, in, in, di, uo,
      di, uo) is det.
+:- mode int.fold_up2(pred(in, in, out, in, out) is semidet, in, in,
+    in, out, in, out) is semidet.
+:- mode int.fold_up2(pred(in, in, out, mdi, muo) is semidet, in, in,
+    in, out, mdi, muo) is semidet.
+:- mode int.fold_up2(pred(in, in, out, di, uo) is semidet, in, in,
+    in, out, di, uo) is semidet.
+:- mode int.fold_up2(pred(in, in, out, in, out) is nondet, in, in,
+    in, out, in, out) is nondet.
+:- mode int.fold_up2(pred(in, in, out, mdi, muo) is nondet, in, in,
+    in, out, mdi, muo) is nondet.

      % fold_down2(F, Low, High, !Acc1, !Acc2) <=>
      %   list.foldr2(F, Low .. High, !Acc1, Acc2).
@@ -309,14 +331,20 @@
  :- pred int.fold_down2(pred(int, T, T, U, U), int, int, T, T, U, U).
  :- mode int.fold_down2(pred(in, in, out, in, out) is det, in, in, in, out,
      in, out) is det.
-:- mode int.fold_down2(pred(in, in, out, in, out) is semidet, in, in,
-    in, out, in, out) is semidet.
-:- mode int.fold_down2(pred(in, in, out, in, out) is nondet, in, in,
-    in, out, in, out) is nondet.
+:- mode int.fold_down2(pred(in, in, out, mdi, muo) is det, in, in, in, out,
+    mdi, muo) is det.
  :- mode int.fold_down2(pred(in, in, out, di, uo) is det, in, in, in, out,
      di, uo) is det.
  :- mode int.fold_down2(pred(in, di, uo, di, uo) is det, in, in, di, uo,
      di, uo) is det.
+:- mode int.fold_down2(pred(in, in, out, in, out) is semidet, in, in,
+    in, out, in, out) is semidet.
+:- mode int.fold_down2(pred(in, in, out, di, uo) is semidet, in, in,
+    in, out, di, uo) is semidet.
+:- mode int.fold_down2(pred(in, in, out, in, out) is nondet, in, in,
+    in, out, in, out) is nondet.
+:- mode int.fold_down2(pred(in, in, out, mdi, muo) is nondet, in, in,
+    in, out, mdi, muo) is nondet.

      % Convert an int to a pretty_printer.doc for formatting.
      %
Index: library/list.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/list.m,v
retrieving revision 1.176
diff -u -r1.176 list.m
--- library/list.m	28 Nov 2008 05:55:14 -0000	1.176
+++ library/list.m	13 Dec 2008 11:59:37 -0000
@@ -701,17 +701,17 @@
      % value in End.
      %
  :- 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, di, uo) is det, in, di, uo) 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, di, uo) is semidet, in, di, uo) 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.
+:- mode list.foldl(pred(in, di, uo) is cc_multi, in, di, uo) is cc_multi.

  :- func list.foldl(func(L, A) = A, list(L), A) = A.

@@ -753,6 +753,8 @@
      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, di, uo) is semidet,
+    in, in, out, di, uo) 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,


--------------------------------------------------------------------------
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