summaryrefslogtreecommitdiff
path: root/src/Identifiers.ml
diff options
context:
space:
mode:
authorSon Ho2021-11-22 21:54:07 +0100
committerSon Ho2021-11-22 21:54:07 +0100
commit5dd233cf1ed8fad120f79f6e002d15607b520cc9 (patch)
tree4e96e3dc30e321b4f4712e750aff7f2f7542eaec /src/Identifiers.ml
parent8b4cb68ac39b3f2b8a7456967898ba4919238234 (diff)
Make progress on write_projection
Diffstat (limited to '')
-rw-r--r--src/Identifiers.ml10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Identifiers.ml b/src/Identifiers.ml
index 04c5427b..dbe2ae83 100644
--- a/src/Identifiers.ml
+++ b/src/Identifiers.ml
@@ -1,3 +1,5 @@
+open Errors
+
(** Signature for a module describing an identifier.
We often need identifiers (for definitions, variables, etc.) and in
@@ -23,6 +25,8 @@ module type Id = sig
val nth_opt : 'a vector -> id -> 'a option
+ val update_nth : 'a vector -> id -> 'a -> 'a vector
+
module Set : Set.S with type elt = id
val set_to_string : Set.t -> string
@@ -63,6 +67,12 @@ module IdGen () : Id = struct
let nth_opt v id = List.nth_opt v id
+ let rec update_nth vec id v =
+ match (vec, id) with
+ | [], _ -> unreachable __LOC__
+ | _ :: vec', 0 -> v :: vec'
+ | x :: vec', _ -> x :: update_nth vec' (id - 1) v
+
module Set = Set.Make (struct
type t = id