[m-rev.] for review: improve documentation for map and bimap folds

Julien Fischer jfischer at opturion.com
Mon Apr 29 14:45:30 AEST 2013


For review by anyone.

The following were suggested by Peter Moulder back in January.
(After the 13.05 release we should go through the standard library and
have a careful look at the consistency -- or lack thereof -- in the
documentation of common operations.)

---------

Documentation clarifications for map and bimap folds.

library/bimap.m:
 	Specify that foldl over a bimap is done by inorder traversal
 	by key.

library/map.m:
 	Likewise for foldl_values and map_foldl.

Julien.

diff --git a/library/bimap.m b/library/bimap.m
index 81f2abe..d04a5e8 100644
--- a/library/bimap.m
+++ b/library/bimap.m
@@ -260,8 +260,8 @@
  :- pred bimap.map_values(pred(K, V, W)::in(pred(in, in, out) is det),
      bimap(K, V)::in, bimap(K, W)::out) is det.

-    % Perform a traversal of the bimap, applying an accumulator predicate
-    % for each key-value pair.
+    % Perform an inorder traversal by key of the bimap, applying an
+    % accumulator predicate for each key-value pair.
      %
  :- 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).
diff --git a/library/map.m b/library/map.m
index 277304b..3eb8d02 100644
--- a/library/map.m
+++ b/library/map.m
@@ -414,8 +414,8 @@
  :- mode map.foldl4(pred(in, in, di, uo, di, uo, di, uo, di, uo) is det,
      in, di, uo, di, uo, di, uo, di, uo) is det.

-    % Perform an inorder traversal of the map, applying
-    % an accumulator predicate for value.
+    % Perform an inorder traversal by key of the map, applying an accumulator
+    % predicate for value.
      %
  :- pred map.foldl_values(pred(V, A, A), map(K, V), A, A).
  :- mode map.foldl_values(pred(in, in, out) is det, in, in, out) is det.
@@ -513,8 +513,8 @@
  :- mode map.map_values_only(pred(in, out) is det, in, out) is det.
  :- mode map.map_values_only(pred(in, out) is semidet, in, out) is semidet.

-    % Apply a transformation predicate to all the values in a map,
-    % while continuously updating an accumulator.
+    % Perform an inorder traversal by key of the map, applying a transformation
+    % predicate to each value while updating an accumulator.
      %
  :- pred map.map_foldl(pred(K, V, W, A, A), map(K, V), map(K, W), A, A).
  :- mode map.map_foldl(pred(in, in, out, in, out) is det, in, out, in, out)



More information about the reviews mailing list