From ac0bc7e011a93d955b5078e27f890e5a6916b412 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Mon, 29 Nov 2021 23:46:20 +0100 Subject: Derive more debugging facilities --- src/Identifiers.ml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/Identifiers.ml') diff --git a/src/Identifiers.ml b/src/Identifiers.ml index e1684f2c..931ec97b 100644 --- a/src/Identifiers.ml +++ b/src/Identifiers.ml @@ -12,6 +12,8 @@ module type Id = sig type 'a vector + type set_t + val zero : id val generator_zero : generator @@ -68,9 +70,13 @@ module type Id = sig val exists : ('a -> bool) -> 'a vector -> bool + val pp_set_t : Format.formatter -> set_t -> unit + + val show_set_t : set_t -> string + module Ord : Map.OrderedType with type t = id - module Set : Set.S with type elt = id + module Set : Set.S with type elt = id with type t = set_t val set_to_string : Set.t -> string @@ -157,6 +163,15 @@ module IdGen () : Id = struct module Set = Set.Make (Ord) module Map = Map.Make (Ord) + type set_t = Set.t + + let show_set_t s = + let ids = Set.fold (fun id s -> to_string id :: s) s [] in + let ids = List.rev ids in + "{" ^ String.concat "," ids ^ "}" + + let pp_set_t fmt s = Format.pp_print_string fmt (show_set_t s) + let set_to_string ids = let ids = Set.fold (fun id ids -> to_string id :: ids) ids [] in "{" ^ String.concat ", " (List.rev ids) ^ "}" -- cgit v1.2.3