From 25139d7bb5f5faac1200bbc7fb98e4fcefa8e944 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Tue, 16 Sep 2014 22:11:42 +0200 Subject: [PATCH] CCPair.print --- core/CCPair.ml | 4 ++++ core/CCPair.mli | 3 +++ 2 files changed, 7 insertions(+) diff --git a/core/CCPair.ml b/core/CCPair.ml index fa15d4c9..21e1b06c 100644 --- a/core/CCPair.ml +++ b/core/CCPair.ml @@ -64,6 +64,10 @@ let compare f g (x1,y1) (x2,y2) = if c <> 0 then c else g y1 y2 type 'a printer = Buffer.t -> 'a -> unit +type 'a formatter = Format.formatter -> 'a -> unit let pp pp_x pp_y buf (x,y) = Printf.bprintf buf "(%a, %a)" pp_x x pp_y y + +let print pa pb fmt (x,y) = + Format.fprintf fmt "(%a, %a)" pa x pb y diff --git a/core/CCPair.mli b/core/CCPair.mli index 1e6ddaf3..e2ccd3ba 100644 --- a/core/CCPair.mli +++ b/core/CCPair.mli @@ -83,5 +83,8 @@ val equal : ('a -> 'a -> bool) -> ('b -> 'b -> bool) -> ('a * 'b) -> ('a * 'b) - val compare : ('a -> 'a -> int) -> ('b -> 'b -> int) -> ('a * 'b) -> ('a * 'b) -> int type 'a printer = Buffer.t -> 'a -> unit +type 'a formatter = Format.formatter -> 'a -> unit val pp : 'a printer -> 'b printer -> ('a*'b) printer + +val print : 'a formatter -> 'b formatter -> ('a*'b) formatter