mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-09 20:55:39 -05:00
23 lines
495 B
OCaml
23 lines
495 B
OCaml
(** Integer-based identifiers. *)
|
|
|
|
module type S = sig
|
|
type t = private int
|
|
|
|
val equal : t -> t -> bool
|
|
val compare : t -> t -> int
|
|
val hash : t -> int
|
|
val to_int : t -> int
|
|
val of_int_unsafe : int -> t
|
|
end
|
|
|
|
(** Generate a new type for integer identifiers *)
|
|
module Make () = struct
|
|
type t = int
|
|
|
|
let equal : t -> t -> bool = ( = )
|
|
let compare : t -> t -> int = compare
|
|
let hash = CCHash.int
|
|
let[@inline] to_int i = i
|
|
|
|
external of_int_unsafe : int -> t = "%identity"
|
|
end
|