Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wish: Format.pp_print_list #3882

Closed
vicuna opened this issue Nov 21, 2005 · 1 comment
Closed

Wish: Format.pp_print_list #3882

vicuna opened this issue Nov 21, 2005 · 1 comment
Assignees

Comments

@vicuna
Copy link

vicuna commented Nov 21, 2005

Original bug ID: 3882
Reporter: Jean-Christophe Filliatre
Assigned to: @gasche
Status: closed (set by @xavierleroy on 2015-12-11T18:29:28Z)
Resolution: fixed
Priority: normal
Severity: feature
Fixed in version: 4.02.0
Category: ~DO NOT USE (was: OCaml general)
Monitored by: pzimmer

Bug description

This is a feature wish.

It would be nice to have a function in Format to print lists, that is something
like

val pp_print_list :
(formatter -> 'a -> unit) -> formatter -> 'a list -> unit

pp_print_list expects a function to print elements, and return a function to
print a list of such elements. This way we could write

fprintf fmt "here is the list %a" (pp_print_list printer) l

It would be even nicer to have a quotation for this. I know that most letters
are already used; let's use %z in this example:

fprintf fmt "here is the list %z" printer l

Additionally, it would be nice to be able to indicate a separator to be printed
between the list elements, for instance:

val pp_print_list :
?sep:(formatter -> unit -> unit) ->
(formatter -> 'a -> unit) -> formatter -> 'a list -> unit

(that would defaults to nothings) and, again, a corresponding quotation:

fprintf fmt "here is the list %Z" printer sep l

where sep is the separator function e.g. (fun fmt () -> fprintf fmt ",@ ")

@vicuna
Copy link
Author

vicuna commented Apr 17, 2015

Comment author: @gasche

This was fixed in 4.02 thanks to Daniel Bünzli's #6009.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants