spacepaste

  1.  
  2. module BetterSet (O: Set.OrderedType) (PBLE: PPRABLE with type t = O.t): (S with type elt = O.t) =
  3. struct
  4. include Set.Make(O)
  5. module M = BetterMap (O) (PBLE)
  6. let to_map = flip (fold (flip M.add ())) M.empty
  7. let sdiff s1 s2 =
  8. M.merge
  9. (fun _ v1 v2 -> match v1, v2 with
  10. | Some (), None
  11. | None, Some () -> Some ()
  12. | _, _ -> None)
  13. (to_map s1)
  14. (to_map s2)
  15. |> M.keys
  16. |> of_enum
  17. end
  18.