From 4ff174ce18d0229bee84ce2a60d207f79a46964e Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Thu, 3 Nov 2016 15:19:50 +0100 Subject: [PATCH] (breaking) make default start/stop arguments empty in printers (#82) --- src/core/CCFormat.ml | 8 ++++---- src/core/CCList.ml | 6 +++--- src/core/CCMap.ml | 4 ++-- src/core/CCPrint.ml | 8 ++++---- src/core/CCSet.ml | 4 ++-- src/core/CCVector.ml | 4 ++-- src/data/CCImmutArray.ml | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/core/CCFormat.ml b/src/core/CCFormat.ml index c7b82288..a2e567ac 100644 --- a/src/core/CCFormat.ml +++ b/src/core/CCFormat.ml @@ -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 -> diff --git a/src/core/CCList.ml b/src/core/CCList.ml index 17a29a04..f09ea9fc 100644 --- a/src/core/CCList.ml +++ b/src/core/CCList.ml @@ -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; diff --git a/src/core/CCMap.ml b/src/core/CCMap.ml index 6dad0ad1..ee7c5f66 100644 --- a/src/core/CCMap.ml +++ b/src/core/CCMap.ml @@ -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 diff --git a/src/core/CCPrint.ml b/src/core/CCPrint.ml index c0f1a4c7..3d1fd7b3 100644 --- a/src/core/CCPrint.ml +++ b/src/core/CCPrint.ml @@ -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 -> diff --git a/src/core/CCSet.ml b/src/core/CCSet.ml index f11d1981..59815a2d 100644 --- a/src/core/CCSet.ml +++ b/src/core/CCSet.ml @@ -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 diff --git a/src/core/CCVector.ml b/src/core/CCVector.ml index 240774fe..1c5362d0 100644 --- a/src/core/CCVector.ml +++ b/src/core/CCVector.ml @@ -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 -> diff --git a/src/data/CCImmutArray.ml b/src/data/CCImmutArray.ml index a775a586..e7e335c6 100644 --- a/src/data/CCImmutArray.ml +++ b/src/data/CCImmutArray.ml @@ -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 (