From bc7a4daa64fec6e6b7d0503145124a703a75ab03 Mon Sep 17 00:00:00 2001 From: Lesenechal Remi Date: Fri, 21 Feb 2020 17:05:52 +0100 Subject: [PATCH] add 'mapi' equivalent for label and constructor maps --- src/stages/common/helpers.ml | 2 ++ src/stages/common/helpers.mli | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/src/stages/common/helpers.ml b/src/stages/common/helpers.ml index d498a1712..5dba263b8 100644 --- a/src/stages/common/helpers.ml +++ b/src/stages/common/helpers.ml @@ -28,6 +28,8 @@ let bind_fold_lmap f init (lmap:_ LMap.t) = let bind_map_lmap f map = bind_lmap (LMap.map f map) let bind_map_cmap f map = bind_cmap (CMap.map f map) +let bind_map_lmapi f map = bind_lmap (LMap.mapi f map) +let bind_map_cmapi f map = bind_cmap (CMap.mapi f map) let range i j = let rec aux i j acc = if i >= j then acc else aux i (j-1) (j-1 :: acc) in diff --git a/src/stages/common/helpers.mli b/src/stages/common/helpers.mli index 69efa24eb..d5e388e36 100644 --- a/src/stages/common/helpers.mli +++ b/src/stages/common/helpers.mli @@ -19,3 +19,12 @@ val is_tuple_lmap : 'a Types.label_map -> bool val get_pair : 'a Types.label_map -> (('a * 'a) * 'b list, unit -> Trace.error) result + + + +val bind_map_lmapi : + (Types.label -> 'a -> ('b * 'c list, 'd) result) -> + 'a Types.label_map -> ('b Types.label_map * 'c list, 'd) result +val bind_map_cmapi : + (Types.constructor' -> 'a -> ('b * 'c list, 'd) result) -> + 'a Types.constructor_map -> ('b Types.constructor_map * 'c list, 'd) result