New handy function for pretty-printing: wrap_print.

This commit is contained in:
Adrien Guatto 2010-07-19 15:13:56 +02:00
parent d75f4f8901
commit 3a0b1f9e16
2 changed files with 7 additions and 0 deletions

View file

@ -245,3 +245,7 @@ let mapi3 f l1 l2 l3 =
(f i v1 v2 v3)::(aux (i+1) l1 l2 l3)
in
aux 0 l1 l2 l3
let wrap_print pp out x =
let fmt = Format.formatter_of_out_channel out in
Format.fprintf fmt "%a@." pp x

View file

@ -179,3 +179,6 @@ val mapi2: (int -> 'a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
val mapi3: (int -> 'a -> 'b -> 'c -> 'd) ->
'a list -> 'b list -> 'c list -> 'd list
(** Enable the use of a plain pretty-printing function with an output channel
instead of a formatter. *)
val wrap_print : (Format.formatter -> 'a -> unit) -> out_channel -> 'a -> unit