diff options
Diffstat (limited to 'src/Identifiers.ml')
-rw-r--r-- | src/Identifiers.ml | 65 |
1 files changed, 7 insertions, 58 deletions
diff --git a/src/Identifiers.ml b/src/Identifiers.ml index ebe0d898..3c07b511 100644 --- a/src/Identifiers.ml +++ b/src/Identifiers.ml @@ -10,16 +10,13 @@ module type Id = sig type generator (** Id generator - simply a counter *) - (* TODO: use list instead *) - type 'a vector - type set_t val zero : id val generator_zero : generator - (* TODO: this is stateful! *) + (* TODO: this is stateful! - but we may want to be able to duplicated contexts... *) val fresh : generator -> id * generator val to_string : id -> string @@ -36,42 +33,21 @@ module type Id = sig val of_int : id -> int - val pp_vector : - (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a vector -> unit - - val show_vector : (Format.formatter -> 'a -> unit) -> 'a vector -> string - - val empty_vector : 'a vector - - val vector_to_list : 'a vector -> 'a list - - val vector_of_list : 'a list -> 'a vector - - val length : 'a vector -> int + val nth : 'a list -> id -> 'a - val nth : 'a vector -> id -> 'a + val nth_opt : 'a list -> id -> 'a option - val nth_opt : 'a vector -> id -> 'a option - - val update_nth : 'a vector -> id -> 'a -> 'a vector - (** Update the nth element of the vector. + val update_nth : 'a list -> id -> 'a -> 'a list + (** Update the nth element of the list. Raises [Invalid_argument] if the identifier is out of range. *) - val iter : ('a -> unit) -> 'a vector -> unit - - val map : ('a -> 'b) -> 'a vector -> 'b vector - - val mapi : (id -> 'a -> 'b) -> 'a vector -> 'b vector + val mapi : (id -> 'a -> 'b) -> 'a list -> 'b list - val mapi_from1 : (id -> 'a -> 'b) -> 'a vector -> 'b vector + val mapi_from1 : (id -> 'a -> 'b) -> 'a list -> 'b list (** Same as [mapi], but where the indices start with 1 *) - val for_all : ('a -> bool) -> 'a vector -> bool - - val exists : ('a -> bool) -> 'a vector -> bool - val pp_set_t : Format.formatter -> set_t -> unit val show_set_t : set_t -> string @@ -85,11 +61,6 @@ module type Id = sig module Map : Map.S with type key = id val id_of_json : Yojson.Basic.t -> (id, string) result - - val vector_of_json : - (Yojson.Basic.t -> ('a, string) result) -> - Yojson.Basic.t -> - ('a vector, string) result end (** Generative functor for identifiers. @@ -102,8 +73,6 @@ module IdGen () : Id = struct type generator = id [@@deriving show] - type 'a vector = 'a list [@@deriving show] - let zero = 0 let generator_zero = 0 @@ -122,14 +91,6 @@ module IdGen () : Id = struct let of_int x = x - let empty_vector = [] - - let vector_to_list v = v - - 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 @@ -140,10 +101,6 @@ module IdGen () : Id = struct | _ :: vec', 0 -> v :: vec' | x :: vec', _ -> x :: update_nth vec' (id - 1) v - let iter = List.iter - - let map = List.map - let mapi = List.mapi let mapi_from1 f ls = @@ -152,10 +109,6 @@ module IdGen () : Id = struct in aux 1 ls - let for_all = List.for_all - - let exists = List.exists - module Ord = struct type t = id @@ -183,10 +136,6 @@ module IdGen () : Id = struct match js with | `Int i -> Ok i | _ -> Error ("id_of_json: failed on " ^ Yojson.Basic.show js) - - let vector_of_json a_of_json js = - OfJsonBasic.combine_error_msgs js "vector_of_json" - (OfJsonBasic.list_of_json a_of_json js) end type name = string list [@@deriving show] |