Closed rizo closed 7 years ago
What do you think about this small newline format combinator?
I think it's bad, that's not the way formatters should be used, it kills compositionality (see also #26). The way of writing what you want is by using a vertical box:
Fmt.(pr "@[<v>%a@]" (list int) [1; 2; 3]);;
1
2
3
or
# Fmt.(pr "%a" (vbox @@ list int) [1; 2; 3]);;
1
2
3
On a related note, before I open a new issue...
Would a Fmt.pl
and Fmt.epl
be acceptable for alternatives to Fmt.pr
and Fmt.epr
that append @.
to the format?
I've seen people (myself including) forget to add @.
way too many times and then wonder why the output is not flushed.
Unlike the originally proposed combinator, this one does not break composition as it only happens at the top-level.
Happy to submit a PR if you're ok with this addition.
Wasn't that discussed in https://github.com/dbuenzli/fmt/issues/26 ?
Missed that one. After reviewing the thread:
Fmt.pl
/Fmt.epl
would break composability – the full format is already formed at the moment of printing;
Fmt.pfl
would break composability and should not be added;@.
or \n
.Fmt.pr
and Fmt.pl
seems strange.
What do you think about this small newline format combinator?
Which can be used like this: