Commit 4696df52 authored by Pietro Abate's avatar Pietro Abate

Use sortedlist for Var.Set to be able to hash properly

parent eed3f263
......@@ -16,15 +16,18 @@ module V = struct
end
type var = [ `Var of V.t ]
type t = var
module VAR = struct
type t = var
let dump ppf (`Var x) = Format.fprintf ppf "%a" V.dump x
let compare (`Var x) (`Var y) = V.compare x y
let equal v1 v2 = (compare v1 v2) = 0
let hash (`Var x) = V.hash x
let check _ = ()
end
include VAR
let id (`Var x) = x.V.id
let dump ppf (`Var x) = Format.fprintf ppf "%a" V.dump x
let pp ppf (`Var x) = Format.fprintf ppf "'%s" x.V.repr
let compare (`Var x) (`Var y) = V.compare x y
let equal v1 v2 = (compare v1 v2) = 0
let hash (`Var x) = V.hash x
let check _ = ()
let mk ?repr id = `Var (V.make_id ?repr id)
let fresh : ?pre: string -> unit -> [> var ] =
......@@ -37,12 +40,14 @@ let fresh : ?pre: string -> unit -> [> var ] =
;;
module Set = struct
include Set.Make(struct type t = var let compare = compare end)
let dump ppf s = Utils.pp_list ~sep:";" ~delim:("{","}") dump ppf (elements s)
let pp ppf s = Utils.pp_list ~sep:";" ~delim:("{","}") pp ppf (elements s)
include SortedList.Make(VAR)
let dump ppf s = Utils.pp_list ~sep:";" ~delim:("{","}") VAR.dump ppf (get s)
let pp ppf s = Utils.pp_list ~sep:";" ~delim:("{","}") pp ppf (get s)
let printf = pp Format.std_formatter
let is_empty s = equal s empty
let from_list l = List.fold_left (fun acc x -> add x acc) empty l
let union = cup
let inter = cap
let cardinal = length
let mem t v = mem v t
end
type 'a pairvar = [ `Atm of 'a | var ]
......
......@@ -13,12 +13,21 @@ val fresh : ?pre:string -> unit -> var
val id : var -> string
module Set : sig
include Set.S with type elt = var
type t
val dump : Format.formatter -> t -> unit
val pp : Format.formatter -> t -> unit
val printf : t -> unit
val is_empty : t -> bool
val from_list : elt list -> t
val empty : t
val singleton : var -> t
val union : t -> t -> t
val diff : t -> t -> t
val mem : var -> t -> bool
val add : var -> t -> t
val inter : t -> t -> t
val subset : t -> t -> bool
val cardinal : t -> int
val from_list : var list -> t
end
type 'a pairvar = [ `Atm of 'a | var ]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment