pp: expose fill and and fill_map

This commit is contained in:
Simon Cruanes 2023-04-01 20:07:59 -04:00
parent 58596a9bd5
commit 1ed81107df
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
2 changed files with 11 additions and 0 deletions

View file

@ -358,6 +358,8 @@ let fill sep = function
in
{ view = Fill { sep; l }; wfl }
let fill_map sep f l = fill sep (List.map f l)
let of_list ?(sep = nil) f l =
let rec loop = function
| [] -> nil

View file

@ -55,6 +55,12 @@ val newline : t
val nl : t
(** Alias for {!newline} *)
val fill : t -> t list -> t
(** [fill sep l] resembles [group (append_l ~sep l)], except it tries
to put as many items of [l] as possible on each line.
In terms of {!Format}, this is like the hov box. *)
(** {2 Output device} *)
(** Arbitrary output.
@ -167,6 +173,9 @@ val append_sp : t list -> t
val append_nl : t list -> t
(** Same as {!append_l} with [sep=nl] *)
val fill_map : t -> ('a -> t) -> 'a list -> t
(** [fill_map sep f l] is [fill sep (List.map f l)] *)
val bool : bool -> t
val int : int -> t
val float : float -> t