summaryrefslogtreecommitdiff
path: root/src/Identifiers.ml
diff options
context:
space:
mode:
authorSon Ho2021-11-23 21:35:20 +0100
committerSon Ho2021-11-23 21:35:20 +0100
commite607decbe559070c7fc76e70739161e1a083dc7c (patch)
tree2fde01e0bc70fb7009d9aa414d1c4b04042e354d /src/Identifiers.ml
parentce5bbb12a1f568050957fa3d1d34d761729d0880 (diff)
Write utilities for the scalars
Diffstat (limited to 'src/Identifiers.ml')
-rw-r--r--src/Identifiers.ml7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Identifiers.ml b/src/Identifiers.ml
index f01d4f47..dc8ae320 100644
--- a/src/Identifiers.ml
+++ b/src/Identifiers.ml
@@ -26,6 +26,8 @@ module type Id = sig
val vector_of_list : 'a list -> 'a vector
+ val length : 'a vector -> int
+
val nth : 'a vector -> id -> 'a
val nth_opt : 'a vector -> id -> 'a option
@@ -55,7 +57,7 @@ end
See [Id].
*)
module IdGen () : Id = struct
- (* TODO: use Int64.t *)
+ (* TODO: use Z.t *)
type id = int
type generator = id
@@ -80,6 +82,8 @@ module IdGen () : Id = struct
let vector_of_list v = v
+ let length v = List.length v
+
let nth v id = List.nth v id
let nth_opt v id = List.nth_opt v id
@@ -111,6 +115,7 @@ module IdGen () : Id = struct
"{" ^ String.concat ", " (List.rev ids) ^ "}"
let id_of_json js =
+ (* TODO: check boundaries ? *)
match js with
| `Int i -> Ok i
| _ -> Error ("id_of_json: failed on " ^ Yojson.Basic.show js)