@@ -32,8 +32,8 @@ module DStd = Dolmen.Std
3232module DE = DStd. Expr
3333
3434type t =
35- | Hstring of Hstring .t
36- | Unique of { name : Hstring .t ; index : int }
35+ | Hstring : Hstring .t -> t
36+ | Dolmen : 'a DE .id -> t
3737
3838(* * Helper function: returns the basename of a dolmen path, since in AE
3939 the problems are contained in one-file (for now at least), the path is
@@ -52,38 +52,32 @@ let get_basename = function
5252 | _ -> ()
5353 ) path
5454
55- let [@ inline always] of_dolmen DE. { path; index; _ } =
56- let name = Hstring. make @@ get_basename path in
57- Unique { name; index = (index :> int ) }
58-
55+ let [@ inline always] of_dolmen id = Dolmen id
5956let [@ inline always] of_hstring hs = Hstring hs
6057let [@ inline always] of_string s = of_hstring @@ Hstring. make s
6158
6259let hash = function
6360 | Hstring hs -> Hstring. hash hs
64- | Unique { index; _ } -> index
61+ | Dolmen { index; _ } -> ( index :> int )
6562
6663let pp ppf = function
6764 | Hstring hs -> Hstring. print ppf hs
68- | Unique { name ; _ } -> Hstring. print ppf name
65+ | Dolmen { path ; _ } -> Fmt. string ppf @@ get_basename path
6966
7067let show = Fmt. to_to_string pp
7168
7269let equal u1 u2 =
7370 match u1, u2 with
7471 | Hstring hs1 , Hstring hs2 -> Hstring. equal hs1 hs2
75- | Unique { index = i1 ; _ } , Unique { index = i2 ; _ } -> i1 = i2
76- | _ -> false
72+ | Dolmen id1 , Dolmen id2 -> DE.Id. equal id1 id2
73+ | _ ->
74+ Hstring. equal (Hstring. make @@ show u1) (Hstring. make @@ show u2)
7775
7876let compare u1 u2 =
7977 match u1, u2 with
8078 | Hstring hs1 , Hstring hs2 -> Hstring. compare hs1 hs2
81- | Unique { index = i1 ; _ } , Unique { index = i2 ; _ } -> i1 - i2
82- | _ -> - 1
83-
84- let rec list_assoc x = function
85- | [] -> raise Not_found
86- | (y , v ) :: l -> if equal x y then v else list_assoc x l
79+ | Dolmen id1 , Dolmen id2 -> DE.Id. compare id1 id2
80+ | _ -> Hstring. compare (Hstring. make @@ show u1) (Hstring. make @@ show u2)
8781
8882module Set = Set. Make
8983 (struct
0 commit comments