Stdlib.Format: add pp_print_seq
parent
4c1654f135
commit
bed23dfbbc
3
Changes
3
Changes
|
@ -137,6 +137,9 @@ Working version
|
|||
|
||||
### Standard library:
|
||||
|
||||
- #9865: add Format.pp_print_seq
|
||||
(Raphaël Proust)
|
||||
|
||||
- #9781: add injectivity annotations to parameterized abstract types
|
||||
(Jeremy Yallop, review by Nicolás Ojeda Bär)
|
||||
|
||||
|
|
|
@ -258,6 +258,7 @@ stdlib__format.cmo : \
|
|||
stdlib__string.cmi \
|
||||
stdlib.cmi \
|
||||
stdlib__stack.cmi \
|
||||
stdlib__seq.cmi \
|
||||
stdlib__queue.cmi \
|
||||
stdlib__list.cmi \
|
||||
stdlib__int.cmi \
|
||||
|
@ -269,6 +270,7 @@ stdlib__format.cmx : \
|
|||
stdlib__string.cmx \
|
||||
stdlib.cmx \
|
||||
stdlib__stack.cmx \
|
||||
stdlib__seq.cmx \
|
||||
stdlib__queue.cmx \
|
||||
stdlib__list.cmx \
|
||||
stdlib__int.cmx \
|
||||
|
@ -278,6 +280,7 @@ stdlib__format.cmx : \
|
|||
stdlib__format.cmi
|
||||
stdlib__format.cmi : \
|
||||
stdlib.cmi \
|
||||
stdlib__seq.cmi \
|
||||
stdlib__buffer.cmi
|
||||
stdlib__fun.cmo : \
|
||||
stdlib__printexc.cmi \
|
||||
|
|
|
@ -1191,6 +1191,22 @@ let rec pp_print_list ?(pp_sep = pp_print_cut) pp_v ppf = function
|
|||
pp_sep ppf ();
|
||||
pp_print_list ~pp_sep pp_v ppf vs
|
||||
|
||||
(* To format a sequence *)
|
||||
let rec pp_print_seq_in ~pp_sep pp_v ppf seq =
|
||||
match seq () with
|
||||
| Seq.Nil -> ()
|
||||
| Seq.Cons (v, seq) ->
|
||||
pp_sep ppf ();
|
||||
pp_v ppf v;
|
||||
pp_print_seq_in ~pp_sep pp_v ppf seq
|
||||
|
||||
let pp_print_seq ?(pp_sep = pp_print_cut) pp_v ppf seq =
|
||||
match seq () with
|
||||
| Seq.Nil -> ()
|
||||
| Seq.Cons (v, seq) ->
|
||||
pp_v ppf v;
|
||||
pp_print_seq_in ~pp_sep pp_v ppf seq
|
||||
|
||||
(* To format free-flowing text *)
|
||||
let pp_print_text ppf s =
|
||||
let len = String.length s in
|
||||
|
|
|
@ -1084,6 +1084,19 @@ val pp_print_list:
|
|||
@since 4.02.0
|
||||
*)
|
||||
|
||||
val pp_print_seq:
|
||||
?pp_sep:(formatter -> unit -> unit) ->
|
||||
(formatter -> 'a -> unit) -> (formatter -> 'a Seq.t -> unit)
|
||||
(** [pp_print_seq ?pp_sep pp_v ppf s] prints items of sequence [s],
|
||||
using [pp_v] to print each item, and calling [pp_sep]
|
||||
between items ([pp_sep] defaults to {!pp_print_cut}.
|
||||
Does nothing on empty sequences.
|
||||
|
||||
This function does not terminate on infinite sequences.
|
||||
|
||||
@since 4.12
|
||||
*)
|
||||
|
||||
val pp_print_text : formatter -> string -> unit
|
||||
(** [pp_print_text ppf s] prints [s] with spaces and newlines respectively
|
||||
printed using {!pp_print_space} and {!pp_force_newline}.
|
||||
|
|
Loading…
Reference in New Issue