diff --git a/core/CCArray.ml b/core/CCArray.ml index 6932c0e6..8d09c7b0 100644 --- a/core/CCArray.ml +++ b/core/CCArray.ml @@ -234,7 +234,7 @@ let _pp_i ~sep pp_item buf a i j = let _print ~sep pp_item fmt a i j = for k = i to j - 1 do - if k > i then Format.pp_print_string fmt sep; + if k > i then (Format.pp_print_string fmt sep; Format.pp_print_cut fmt ()); pp_item fmt a.(k) done diff --git a/core/CCBool.ml b/core/CCBool.ml index 0712e58b..ac61291f 100644 --- a/core/CCBool.ml +++ b/core/CCBool.ml @@ -36,4 +36,4 @@ type 'a printer = Buffer.t -> 'a -> unit type 'a formatter = Format.formatter -> 'a -> unit let pp buf = Printf.bprintf buf "%B" -let print fmt = Format.fprintf fmt "%B" +let print fmt = Format.pp_print_bool fmt diff --git a/core/CCError.ml b/core/CCError.ml index 851cd5c1..eb8990f6 100644 --- a/core/CCError.ml +++ b/core/CCError.ml @@ -230,5 +230,5 @@ let pp pp_x buf e = match e with | `Error s -> Printf.bprintf buf "error(%s)" s let print pp_x fmt e = match e with - | `Ok x -> Format.fprintf fmt "ok(%a)" pp_x x - | `Error s -> Format.fprintf fmt "error(%s)" s + | `Ok x -> Format.fprintf fmt "@[ok(@,%a)@]" pp_x x + | `Error s -> Format.fprintf fmt "@[error(@,%s)@]" s diff --git a/core/CCInt.ml b/core/CCInt.ml index 57e0c2dc..29a898e3 100644 --- a/core/CCInt.ml +++ b/core/CCInt.ml @@ -46,4 +46,4 @@ let random_small = random 100 let random_range i j st = i + random (j-i) st let pp buf = Printf.bprintf buf "%d" -let print fmt = Format.fprintf fmt "%d" +let print fmt = Format.pp_print_int fmt diff --git a/core/CCKList.ml b/core/CCKList.ml index 2b22e399..4e253a1a 100644 --- a/core/CCKList.ml +++ b/core/CCKList.ml @@ -361,7 +361,11 @@ let pp ?(sep=",") pp_item buf l = let print ?(sep=",") pp_item fmt l = let rec pp fmt l = match l() with | `Nil -> () - | `Cons (x,l') -> Format.pp_print_string fmt sep; pp_item fmt x; pp fmt l' + | `Cons (x,l') -> + Format.pp_print_string fmt sep; + Format.pp_print_cut fmt (); + pp_item fmt x; + pp fmt l' in match l() with | `Nil -> () diff --git a/core/CCList.ml b/core/CCList.ml index ddb0fa5c..64d93a0c 100644 --- a/core/CCList.ml +++ b/core/CCList.ml @@ -679,8 +679,11 @@ let print ?(start="[") ?(stop="]") ?(sep=", ") pp_item fmt l = | x::((y::xs) as l) -> pp_item fmt x; Format.pp_print_string fmt sep; + Format.pp_print_cut fmt (); print fmt l | x::[] -> pp_item fmt x | [] -> () in - Format.fprintf fmt "@[%s%a%s@]" start print l stop + Format.pp_print_string fmt start; + print fmt l; + Format.pp_print_string fmt stop diff --git a/core/CCPersistentHashtbl.ml b/core/CCPersistentHashtbl.ml index 71c1610c..70c4df91 100644 --- a/core/CCPersistentHashtbl.ml +++ b/core/CCPersistentHashtbl.ml @@ -343,7 +343,8 @@ module Make(H : HashedType) : S with type key = H.t = struct let first = ref true in iter t (fun k v -> - if !first then first:=false else Format.pp_print_string fmt ", "; + if !first then first:=false + else (Format.pp_print_string fmt ", "; Format.pp_print_cut fmt ()); Format.fprintf fmt "%a -> %a" pp_k k pp_v v ); Format.pp_print_string fmt "}" diff --git a/core/CCVector.ml b/core/CCVector.ml index d4809056..e9675f23 100644 --- a/core/CCVector.ml +++ b/core/CCVector.ml @@ -486,10 +486,10 @@ let pp ?(start="[") ?(stop="]") ?(sep=", ") pp_item buf v = Buffer.add_string buf stop let print ?(start="[") ?(stop="]") ?(sep=", ") pp_item fmt v = - Format.fprintf fmt "@[%s" start; + Format.pp_print_string fmt start; iteri (fun i x -> - if i > 0 then Format.pp_print_string fmt sep; + if i > 0 then (Format.pp_print_string fmt sep; Format.pp_print_cut fmt()); pp_item fmt x ) v; - Format.fprintf fmt "%s@]" stop + Format.pp_print_string fmt stop