(breaking) make default start/stop arguments empty in printers (#82)

This commit is contained in:
Simon Cruanes 2016-11-03 15:19:50 +01:00
parent 269d4a7ba9
commit 4ff174ce18
7 changed files with 18 additions and 18 deletions

View file

@ -25,7 +25,7 @@ let int64 fmt n = Format.fprintf fmt "%Ld" n
let nativeint fmt n = Format.fprintf fmt "%nd" n
let string_quoted fmt s = Format.fprintf fmt "\"%s\"" s
let list ?(start="[") ?(stop="]") ?(sep=", ") pp fmt l =
let list ?(start="") ?(stop="") ?(sep=", ") pp fmt l =
let rec pp_list l = match l with
| x::((_::_) as l) ->
pp fmt x;
@ -39,7 +39,7 @@ let list ?(start="[") ?(stop="]") ?(sep=", ") pp fmt l =
pp_list l;
Format.pp_print_string fmt stop
let array ?(start="[") ?(stop="]") ?(sep=", ") pp fmt a =
let array ?(start="") ?(stop="") ?(sep=", ") pp fmt a =
Format.pp_print_string fmt start;
for i = 0 to Array.length a - 1 do
if i > 0 then (
@ -50,7 +50,7 @@ let array ?(start="[") ?(stop="]") ?(sep=", ") pp fmt a =
done;
Format.pp_print_string fmt stop
let arrayi ?(start="[") ?(stop="]") ?(sep=", ") pp fmt a =
let arrayi ?(start="") ?(stop="") ?(sep=", ") pp fmt a =
Format.pp_print_string fmt start;
for i = 0 to Array.length a - 1 do
if i > 0 then (
@ -61,7 +61,7 @@ let arrayi ?(start="[") ?(stop="]") ?(sep=", ") pp fmt a =
done;
Format.pp_print_string fmt stop
let seq ?(start="[") ?(stop="]") ?(sep=", ") pp fmt seq =
let seq ?(start="") ?(stop="") ?(sep=", ") pp fmt seq =
Format.pp_print_string fmt start;
let first = ref true in
seq (fun x ->

View file

@ -1221,7 +1221,7 @@ end
(** {2 IO} *)
let pp ?(start="[") ?(stop="]") ?(sep=", ") pp_item buf l =
let pp ?(start="") ?(stop="") ?(sep=", ") pp_item buf l =
let rec print l = match l with
| x::((_::_) as l) ->
pp_item buf x;
@ -1232,10 +1232,10 @@ let pp ?(start="[") ?(stop="]") ?(sep=", ") pp_item buf l =
in Buffer.add_string buf start; print l; Buffer.add_string buf stop
(*$T
CCPrint.to_string (pp CCPrint.int) [1;2;3] = "[1, 2, 3]"
CCPrint.to_string (pp ~start:"[" ~stop:"]" CCPrint.int) [1;2;3] = "[1, 2, 3]"
*)
let print ?(start="[") ?(stop="]") ?(sep=", ") pp_item fmt l =
let print ?(start="") ?(stop="") ?(sep=", ") pp_item fmt l =
let rec print fmt l = match l with
| x::((_::_) as l) ->
pp_item fmt x;

View file

@ -113,7 +113,7 @@ module Make(O : Map.OrderedType) = struct
let to_list m =
fold (fun k v acc -> (k,v)::acc) m []
let pp ?(start="{") ?(stop="}") ?(arrow="->") ?(sep=", ") pp_k pp_v buf m =
let pp ?(start="") ?(stop="") ?(arrow="->") ?(sep=", ") pp_k pp_v buf m =
let first = ref true in
Buffer.add_string buf start;
iter
@ -125,7 +125,7 @@ module Make(O : Map.OrderedType) = struct
m;
Buffer.add_string buf stop
let print ?(start="[") ?(stop="]") ?(arrow="->") ?(sep=", ") pp_k pp_v fmt m =
let print ?(start="") ?(stop="") ?(arrow="->") ?(sep=", ") pp_k pp_v fmt m =
Format.pp_print_string fmt start;
let first = ref true in
iter

View file

@ -25,7 +25,7 @@ let float3 buf f = Printf.bprintf buf "%.3f" f
let float buf f = Buffer.add_string buf (string_of_float f)
let char buf c = Buffer.add_char buf c
let list ?(start="[") ?(stop="]") ?(sep=", ") pp buf l =
let list ?(start="") ?(stop="") ?(sep=", ") pp buf l =
let rec pp_list l = match l with
| x::((_::_) as l) ->
pp buf x;
@ -38,7 +38,7 @@ let list ?(start="[") ?(stop="]") ?(sep=", ") pp buf l =
pp_list l;
Buffer.add_string buf stop
let array ?(start="[") ?(stop="]") ?(sep=", ") pp buf a =
let array ?(start="") ?(stop="") ?(sep=", ") pp buf a =
Buffer.add_string buf start;
for i = 0 to Array.length a - 1 do
(if i > 0 then Buffer.add_string buf sep);
@ -46,7 +46,7 @@ let array ?(start="[") ?(stop="]") ?(sep=", ") pp buf a =
done;
Buffer.add_string buf stop
let arrayi ?(start="[") ?(stop="]") ?(sep=", ") pp buf a =
let arrayi ?(start="") ?(stop="") ?(sep=", ") pp buf a =
Buffer.add_string buf start;
for i = 0 to Array.length a - 1 do
(if i > 0 then Buffer.add_string buf sep);
@ -54,7 +54,7 @@ let arrayi ?(start="[") ?(stop="]") ?(sep=", ") pp buf a =
done;
Buffer.add_string buf stop
let seq ?(start="[") ?(stop="]") ?(sep=", ") pp buf seq =
let seq ?(start="") ?(stop="") ?(sep=", ") pp buf seq =
Buffer.add_string buf start;
let first = ref true in
seq (fun x ->

View file

@ -51,7 +51,7 @@ module Make(O : Map.OrderedType) = struct
let to_list = elements
let pp ?(start="{") ?(stop="}") ?(sep=", ") pp_x buf m =
let pp ?(start="") ?(stop="") ?(sep=", ") pp_x buf m =
let first = ref true in
Buffer.add_string buf start;
iter
@ -61,7 +61,7 @@ module Make(O : Map.OrderedType) = struct
m;
Buffer.add_string buf stop
let print ?(start="[") ?(stop="]") ?(sep=", ") pp_x fmt m =
let print ?(start="") ?(stop="") ?(sep=", ") pp_x fmt m =
Format.pp_print_string fmt start;
let first = ref true in
iter

View file

@ -737,7 +737,7 @@ let to_klist v =
else `Cons (v.vec.(i), aux (i+1))
in aux 0
let pp ?(start="[") ?(stop="]") ?(sep=", ") pp_item buf v =
let pp ?(start="") ?(stop="") ?(sep=", ") pp_item buf v =
Buffer.add_string buf start;
iteri
(fun i x ->
@ -746,7 +746,7 @@ let pp ?(start="[") ?(stop="]") ?(sep=", ") pp_item buf v =
) v;
Buffer.add_string buf stop
let print ?(start="[") ?(stop="]") ?(sep=", ") pp_item fmt v =
let print ?(start="") ?(stop="") ?(sep=", ") pp_item fmt v =
Format.pp_print_string fmt start;
iteri
(fun i x ->

View file

@ -116,7 +116,7 @@ let to_gen a =
type 'a printer = Format.formatter -> 'a -> unit
let print ?(start="[|") ?(stop="|]") ?(sep=";") pp_item out a =
let print ?(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 (