From 5add9742422612532f3a851e0b11cb32d07d0e07 Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Thu, 28 Feb 2019 03:30:51 -0800 Subject: [PATCH] Express MakePPMonoMap in terms of MakePPMap Reviewed By: skcho Differential Revision: D14243587 fbshipit-source-id: 12aa08147 --- infer/src/istd/PrettyPrintable.ml | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/infer/src/istd/PrettyPrintable.ml b/infer/src/istd/PrettyPrintable.ml index 48e08c5fb..fa2aa14b8 100644 --- a/infer/src/istd/PrettyPrintable.ml +++ b/infer/src/istd/PrettyPrintable.ml @@ -170,26 +170,15 @@ module type PPMonoMap = sig val pp_key : F.formatter -> key -> unit end -module MakePPMonoMap (Ord : PrintableOrderedType) (Val : PrintableType) = struct - module M = Caml.Map.Make (Ord) - - include (M : module type of M with type 'a t := 'a M.t) +module PPMonoMapOfPPMap (M : PPMap) (Val : PrintableType) = struct + include (M : module type of M with type key = M.key and type 'a t := 'a M.t) type t = Val.t M.t type value = Val.t - let pp_key = Ord.pp - - let pp fmt m = - let pp_item fmt (k, v) = F.fprintf fmt "%a -> %a" Ord.pp k Val.pp v in - pp_collection ~pp_item fmt (bindings m) - - - let is_singleton_or_more m = - if is_empty m then IContainer.Empty - else - let ((kmi, _) as binding) = min_binding m in - let kma, _ = max_binding m in - if phys_equal kmi kma then IContainer.Singleton binding else IContainer.More + let pp = pp ~pp_value:Val.pp end + +module MakePPMonoMap (Ord : PrintableOrderedType) (Val : PrintableType) = + PPMonoMapOfPPMap (MakePPMap (Ord)) (Val)