module BetterSet (O: Set.OrderedType) (PBLE: PPRABLE with type t = O.t): (S with type elt = O.t) = struct include Set.Make(O) module M = BetterMap (O) (PBLE) let to_map = flip (fold (flip M.add ())) M.empty let sdiff s1 s2 = M.merge (fun _ v1 v2 -> match v1, v2 with | Some (), None | None, Some () -> Some () | _, _ -> None) (to_map s1) (to_map s2) |> M.keys |> of_enum end