module rec A : sig type t = Leaf of string | Node of ASet.t val compare: t -> t -> int end = struct type t = Leaf of string | Node of ASet.t let compare t1 t2 = match (t1, t2) with | (Leaf s1, Leaf s2) -> Pervasives.compare s1 s2 | (Leaf _, Node _) -> 1 | (Node _, Leaf _) -> -1 | (Node n1, Node n2) -> ASet.compare n1 n2 end and ASet : Set.S with type elt = A.t = Set.Make(A) let a = A.Leaf "a" let b = A.Leaf "b" let ab = A.Node (ASet.add a (ASet.add b ASet.empty)) let ba = A.Node (ASet.add b (ASet.add a ASet.empty)) let c = A.Node (ASet.add a (ASet.add ab ASet.empty)) let () = assert (A.compare ab ba = 0) ; assert (A.compare ab c <> 0) ; Printf.printf "Tout bon!\n"