summaryrefslogtreecommitdiff
path: root/typing/types.ml
diff options
context:
space:
mode:
authorThomas Refis <thomas.refis@gmail.com>2020-02-27 16:50:16 +0100
committerThomas Refis <thomas.refis@gmail.com>2020-03-05 13:36:11 +0100
commit3fe25383ba9992d1818f6fa8a3a99d05a38a1da4 (patch)
tree6c8c96bd2c892336b51abacc52706fa2d4346593 /typing/types.ml
parent6063e73d3a3bcce066a631fca6aeebcbadb1c181 (diff)
downloadocaml-3fe25383ba9992d1818f6fa8a3a99d05a38a1da4.tar.gz
Types.Uid: include Identifiable
Diffstat (limited to 'typing/types.ml')
-rw-r--r--typing/types.ml18
1 files changed, 18 insertions, 0 deletions
diff --git a/typing/types.ml b/typing/types.ml
index e931059f54..e6b1dedd85 100644
--- a/typing/types.ml
+++ b/typing/types.ml
@@ -88,6 +88,24 @@ module Uid = struct
| Internal
| Predef of string
+ include Identifiable.Make(struct
+ type nonrec t = t
+
+ let equal (x : t) y = x = y
+ let compare (x : t) y = compare x y
+ let hash (x : t) = Hashtbl.hash x
+
+ let print fmt = function
+ | Internal -> Format.pp_print_string fmt "<internal>"
+ | Predef name -> Format.fprintf fmt "<predef:%s>" name
+ | Compilation_unit s -> Format.pp_print_string fmt s
+ | Item { comp_unit; id } -> Format.fprintf fmt "%s.%d" comp_unit id
+
+ let output oc t =
+ let fmt = Format.formatter_of_out_channel oc in
+ print fmt t
+ end)
+
let mk =
let id = ref (-1) in
fun ~current_unit ->