X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=finiteCofinite.ml;h=58f07306f9595081958d7215b472af8b9187d2e3;hb=d550133ad7afdf65c5e284c2bcf67a5bdde6faa7;hp=32f0e4887a16f45370303f2d34267bf052933b7e;hpb=d04661689691b4587cfc45a35e98604fcdc2b878;p=SXSI%2Fxpathcomp.git diff --git a/finiteCofinite.ml b/finiteCofinite.ml index 32f0e48..58f0730 100644 --- a/finiteCofinite.ml +++ b/finiteCofinite.ml @@ -10,6 +10,7 @@ module type S = sig type elt type t + type set val empty : t val any : t val is_empty : t -> bool @@ -38,14 +39,16 @@ sig val choose : t -> elt val hash : t -> int val equal : t -> t -> bool + val positive : t -> set + val negative : t -> set end -module Make (E : Sigs.Set) : S with type elt = E.elt = +module Make (E : Sigs.Set) : S with type elt = E.elt and type set = E.t = struct type elt = E.elt type t = Finite of E.t | CoFinite of E.t - + type set = E.t let empty = Finite E.empty let any = CoFinite E.empty @@ -179,5 +182,15 @@ struct function Finite x -> (E.hash x) | CoFinite x -> ( ~-(E.hash x) land max_int) + let positive = + function + | Finite x -> x + | _ -> E.empty + + let negative = + function + | CoFinite x -> x + | _ -> E.empty + end