sidekick/src/base/ID.mli
2022-08-27 20:24:28 -04:00

47 lines
1.5 KiB
OCaml

(* This file is free software. See file "license" for more details. *)
(** Unique Identifiers *)
(**
We use generative identifiers everywhere in [Sidekick_base]. Unlike
strings, there are no risk of collision: during parsing, a new
declaration or definition should create a fresh [ID.t] and associate
it with the string name, and later references should look into some hashtable
or map to get the ID corresponding to a string.
This allows us to handle definition shadowing or binder shadowing easily.
*)
type t
(** The opaque type of unique identifiers *)
val make : string -> t
(** [make s] creates a new identifier with name [s]
and some internal information. It is different than any other identifier
created before or after, even with the same name. *)
val makef : ('a, Format.formatter, unit, t) format4 -> 'a
(** [makef "foo %d bar %b" 42 true] is like
[make (Format.asprintf "foo %d bar %b" 42 true)]. *)
val copy : t -> t
(** Fresh copy of the identifier, distinct from it, but with the
same name. *)
val id : t -> int
(** Unique integer counter for this identifier. *)
val to_string : t -> string
(** Print identifier. *)
val to_string_full : t -> string
(** Printer name and unique counter for this ID. *)
include Sidekick_sigs.EQ_ORD_HASH_PRINT with type t := t
val pp_name : t CCFormat.printer
val pp_full : t CCFormat.printer
module Map : CCMap.S with type key = t
module Set : CCSet.S with type elt = t
module Tbl : CCHashtbl.S with type key = t