module Category = struct type t = Unlisted | Published | Invalid | Custom of string let compare = Stdlib.compare let of_string = function "unlisted" | "published" -> Invalid | c -> Custom c let to_string = function Custom c -> c | _ -> "" end include Category module CategorySet = struct include Set.Make (Category) let of_stringset s = String_set.fold (fun e a -> add (Category.of_string e) a) s empty let of_query q = of_stringset (fst q), of_stringset (snd q) let predicate (inc, exl) set = not (disjoint inc set) && disjoint exl set let of_string x = of_stringset (String_set.of_string x) let to_string set = let f elt a = let s = Category.to_string elt in if a <> "" then a ^ ", " ^ s else s in fold f set "" end