-
- module type SF = sig
- type elt
- module S: Set.S with type elt = elt
- val of_list: S.elt list -> S.t
- val map: (S.elt -> S.elt) -> S.t -> S.t
- val ppr: Format.formatter -> S.t -> unit
- end
-
- module SetFuns (OT: Map.OrderedType) (SBLE: STRINGABLE with type t = OT.t) : (SF with type elt = OT.t) =
- struct
- module S = Set.Make(OT)
-
- let of_list l = List.fold_right S.add l S.empty
-
- (* map from Set to Set of the same type. currying heaven. *)
- let map f s = S.fold (fun x -> S.add (f x)) s S.empty
-
- let ppr ff s =
- Format.fprintf ff "@[{";
- ppr_list_inners (
- fun ff x ->
- Format.fprintf ff "%s" (SBLE.to_string x);
- ) ff (S.elements s);
- Format.fprintf ff "}@]"
- end
-