diff options
author | Son Ho | 2021-11-23 21:35:20 +0100 |
---|---|---|
committer | Son Ho | 2021-11-23 21:35:20 +0100 |
commit | e607decbe559070c7fc76e70739161e1a083dc7c (patch) | |
tree | 2fde01e0bc70fb7009d9aa414d1c4b04042e354d /src/Identifiers.ml | |
parent | ce5bbb12a1f568050957fa3d1d34d761729d0880 (diff) |
Write utilities for the scalars
Diffstat (limited to 'src/Identifiers.ml')
-rw-r--r-- | src/Identifiers.ml | 7 |
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) |