rename print to pp for Format printers (closes #153)

This commit is contained in:
Simon Cruanes 2018-01-14 17:58:20 -06:00
parent 19b2b7c7cc
commit fc329fa118
22 changed files with 50 additions and 42 deletions

View file

@ -124,7 +124,7 @@ module Poly = struct
()
*)
let print pp_k pp_v fmt m =
let pp pp_k pp_v fmt m =
Format.fprintf fmt "@[<hov2>tbl {@,";
let first = ref true in
Hashtbl.iter
@ -232,9 +232,10 @@ module type S = sig
to [tbl] and [v] is returned.
@since 1.0 *)
val print : key printer -> 'a printer -> 'a t printer
(** Printer for tables
@since 0.13 *)
val pp : key printer -> 'a printer -> 'a t printer
(** Printer for table
@since 0.13
Renamed from [print] @since NEXT_RELEASE *)
end
(*$inject
@ -344,7 +345,7 @@ module Make(X : Hashtbl.HashedType)
List.iter (fun (k,v) -> add tbl k v) l;
tbl
let print pp_k pp_v fmt m =
let pp pp_k pp_v fmt m =
Format.fprintf fmt "@[<hov2>tbl {@,";
let first = ref true in
iter

View file

@ -102,9 +102,10 @@ module Poly : sig
to [tbl] and [v] is returned.
@since 1.0 *)
val print : 'a printer -> 'b printer -> ('a, 'b) Hashtbl.t printer
val pp : 'a printer -> 'b printer -> ('a, 'b) Hashtbl.t printer
(** Printer for table
@since 0.13 *)
@since 0.13
Renamed from [print] @since NEXT_RELEASE *)
end
include module type of Poly
@ -201,9 +202,10 @@ module type S = sig
to [tbl] and [v] is returned.
@since 1.0 *)
val print : key printer -> 'a printer -> 'a t printer
val pp : key printer -> 'a printer -> 'a t printer
(** Printer for tables
@since 0.13 *)
@since 0.13
Renamed from {!print} @since NEXT_RELEASE *)
end
module Make(X : Hashtbl.HashedType) :

View file

@ -52,8 +52,8 @@ module type S = sig
val to_klist : t -> char klist
val to_list : t -> char list
val pp : Buffer.t -> t -> unit
val print : Format.formatter -> t -> unit
val pp_buf : Buffer.t -> t -> unit
val pp : Format.formatter -> t -> unit
end
let equal (a:string) b = Pervasives.(=) a b
@ -783,12 +783,12 @@ let equal_caseless s1 s2: bool =
(fun c1 c2 -> CCChar.equal (CCChar.lowercase_ascii c1) (CCChar.lowercase_ascii c2))
s1 s2
let pp buf s =
let pp_buf buf s =
Buffer.add_char buf '"';
Buffer.add_string buf s;
Buffer.add_char buf '"'
let print fmt s =
let pp fmt s =
Format.fprintf fmt "\"%s\"" s
module Sub = struct
@ -830,11 +830,11 @@ module Sub = struct
let to_klist (s,i,len) = _to_klist s i len
let to_list (s,i,len) = _to_list s [] i len
let pp buf (s,i,len) =
let pp_buf buf (s,i,len) =
Buffer.add_char buf '"';
Buffer.add_substring buf s i len;
Buffer.add_char buf '"'
let print fmt s =
let pp fmt s =
Format.fprintf fmt "\"%s\"" (copy s)
end

View file

@ -41,9 +41,12 @@ module type S = sig
val to_klist : t -> char klist
val to_list : t -> char list
val pp : Buffer.t -> t -> unit
val print : Format.formatter -> t -> unit
(** Print the string within quotes *)
val pp_buf : Buffer.t -> t -> unit
(** Renamed from [pp] @since NEXT_RELEASE *)
val pp : Format.formatter -> t -> unit
(** Print the string within quotes
Renamed from [print] @since NEXT_RELEASE *)
end
(** {2 Strings} *)
@ -718,7 +721,7 @@ module Sub : sig
(*$T
let sub = Sub.make " abc " 1 ~len:3 in \
"\"abc\"" = (CCFormat.to_string Sub.print sub)
"\"abc\"" = (CCFormat.to_string Sub.pp sub)
*)
(*$= & ~printer:(String.make 1)

View file

@ -549,7 +549,7 @@ let of_seq seq =
|> CCList.of_seq |> List.sort CCOrd.compare = CCList.range 0 10
*)
let print out bv =
let pp out bv =
Format.pp_print_string out "bv {";
iter bv
(fun _i b ->

View file

@ -142,6 +142,6 @@ type 'a sequence = ('a -> unit) -> unit
val to_seq : t -> int sequence
val of_seq : int sequence -> t
val print : Format.formatter -> t -> unit
val pp : Format.formatter -> t -> unit
(** Print the bitvector as a string of bits
@since 0.13 *)

View file

@ -405,7 +405,7 @@ let compare ~cmp a b =
type 'a printer = Format.formatter -> 'a -> unit
let print pp_x out d =
let pp pp_x out d =
let first = ref true in
Format.fprintf out "@[<hov2>deque {";
iter

View file

@ -124,6 +124,6 @@ val to_rev_list : 'a t -> 'a list
type 'a printer = Format.formatter -> 'a -> unit
val print : 'a printer -> 'a t printer
val pp : 'a printer -> 'a t printer
(** Print the elements
@since 0.13 *)

View file

@ -515,7 +515,7 @@ let (--^) a b =
0 --^ 0 |> to_list = []
*)
let print pp_x out d =
let pp pp_x out d =
let first = ref true in
Format.fprintf out "@[<hov2>queue {";
iter

View file

@ -135,5 +135,5 @@ val (--^) : int -> int -> int t
(** [a -- b] is the integer range from [a] to [b], where [b] is excluded.
@since 0.17 *)
val print : 'a printer -> 'a t printer
val pp : 'a printer -> 'a t printer
(** @since 0.13 *)

View file

@ -126,7 +126,7 @@ module type S = sig
(** {6 IO} *)
val print : key printer -> 'a printer -> 'a t printer
val pp : key printer -> 'a printer -> 'a t printer
val as_tree : 'a t -> [`L of int * (key * 'a) list | `N ] ktree
(** For debugging purpose: explore the structure of the tree,
@ -698,7 +698,7 @@ module Make(Key : KEY)
| None -> raise Not_found
| Some (k,v) -> k, v
let print ppk ppv out m =
let pp ppk ppv out m =
let first = ref true in
iter m
~f:(fun k v ->

View file

@ -138,7 +138,8 @@ module type S = sig
(** {6 IO} *)
val print : key printer -> 'a printer -> 'a t printer
val pp : key printer -> 'a printer -> 'a t printer
(** Renamed from [val print] @since NEXT_RELEASE *)
val as_tree : 'a t -> [`L of int * (key * 'a) list | `N ] ktree
(** For debugging purpose: explore the structure of the tree,

View file

@ -118,7 +118,7 @@ let to_gen a =
type 'a printer = Format.formatter -> 'a -> unit
let print ?(start="") ?(stop="") ?(sep=", ") pp_item out a =
let pp ?(start="") ?(stop="") ?(sep=", ") pp_item out a =
Format.pp_print_string out start;
for k = 0 to Array.length a - 1 do
if k > 0 then (

View file

@ -88,7 +88,7 @@ val to_gen : 'a t -> 'a gen
type 'a printer = Format.formatter -> 'a -> unit
val print :
val pp :
?start:string -> ?stop:string -> ?sep:string ->
'a printer -> 'a t printer

View file

@ -326,14 +326,14 @@ let rec union f t1 t2 =
*)
(*$R
assert_equal ~cmp:(equal ~eq:(=)) ~printer:(CCFormat.to_string (print CCString.print))
assert_equal ~cmp:(equal ~eq:(=)) ~printer:(CCFormat.to_string (pp CCString.pp))
(of_list [1, "1"; 2, "2"; 3, "3"; 4, "4"])
(union (fun _ a b -> a)
(of_list [1, "1"; 3, "3"]) (of_list [2, "2"; 4, "4"]));
*)
(*$R
assert_equal ~cmp:(equal ~eq:(=)) ~printer:(CCFormat.to_string (print CCString.print))
assert_equal ~cmp:(equal ~eq:(=)) ~printer:(CCFormat.to_string (pp CCString.pp))
(of_list [1, "1"; 2, "2"; 3, "3"; 4, "4"])
(union (fun _ a b -> a)
(of_list [1, "1"; 2, "2"; 3, "3"]) (of_list [2, "2"; 4, "4"]))
@ -369,7 +369,7 @@ let rec inter f a b =
else E
(*$R
assert_equal ~cmp:(equal ~eq:(=)) ~printer:(CCFormat.to_string (print CCString.print))
assert_equal ~cmp:(equal ~eq:(=)) ~printer:(CCFormat.to_string (pp CCString.pp))
(singleton 2 "2")
(inter (fun _ a b -> a)
(of_list [1, "1"; 2, "2"; 3, "3"]) (of_list [2, "2"; 4, "4"]))
@ -533,7 +533,7 @@ let rec as_tree t () = match t with
type 'a printer = Format.formatter -> 'a -> unit
let print pp_x out m =
let pp pp_x out m =
Format.fprintf out "@[<hov2>intmap {@,";
let first = ref true in
iter

View file

@ -107,7 +107,7 @@ val as_tree : 'a t -> [`Node of int * int | `Leaf of int * 'a ] tree
type 'a printer = Format.formatter -> 'a -> unit
val print : 'a printer -> 'a t printer
val pp : 'a printer -> 'a t printer
(** @since 0.13 *)
(** Helpers *)

View file

@ -163,7 +163,7 @@ let to_gen a =
type 'a printer = Format.formatter -> 'a -> unit
let print pp_item out v =
let pp pp_item out v =
Format.fprintf out "[|";
iteri
(fun i x ->

View file

@ -131,5 +131,5 @@ val to_gen : 'a t -> 'a gen
type 'a printer = Format.formatter -> 'a -> unit
val print : 'a printer -> 'a t printer
val pp : 'a printer -> 'a t printer
(** @since 0.13 *)

View file

@ -576,7 +576,7 @@ include Infix
type 'a printer = Format.formatter -> 'a -> unit
let print ?(sep=", ") pp_item fmt l =
let pp ?(sep=", ") pp_item fmt l =
let first = ref true in
iter l
~f:(fun x ->

View file

@ -187,4 +187,4 @@ include module type of Infix
type 'a printer = Format.formatter -> 'a -> unit
val print : ?sep:string -> 'a printer -> 'a t printer
val pp : ?sep:string -> 'a printer -> 'a t printer

View file

@ -161,7 +161,7 @@ module type S = sig
val to_gen : 'a t -> (key * 'a) gen
val print : key printer -> 'a printer -> 'a t printer
val pp : key printer -> 'a printer -> 'a t printer
(**/**)
val node_ : key -> 'a -> 'a t -> 'a t -> 'a t
@ -588,7 +588,7 @@ module MakeFull(K : KEY) : S with type key = K.t = struct
Some (k,v)
in next
let print pp_k pp_v fmt m =
let pp pp_k pp_v fmt m =
let start = "[" and stop = "]" and arrow = "->" and sep = ","in
Format.pp_print_string fmt start;
let first = ref true in

View file

@ -126,7 +126,8 @@ module type S = sig
val to_gen : 'a t -> (key * 'a) gen
val print : key printer -> 'a printer -> 'a t printer
val pp : key printer -> 'a printer -> 'a t printer
(** Renamed from [val print] @since NEXT_RELEASE *)
(**/**)
val node_ : key -> 'a -> 'a t -> 'a t -> 'a t