Closed Drup closed 4 years ago
Currently custom formats (CamlinternalFormatBasics.Custom
) have to return a string. When integrating the patch in the compiler we talked about generalizing them so they could be used with a Format.formatter
but decided it wasn't worth the effort, at least initially. This is because the Format.formatter
type would need to be defined before the CamlinternalFormatBasics.format6
type, so a few things would need to be moved around in the stdlib. If there is demand for it, it can probably be reconsidered.
Ccing @gasche and @bvaugon
I think it's worth the effort. to_string
functions are not the way you should compose pretty printers (as they ignore both indentation and tag on the target).
Realistically, we're not going to make this happen. First because the stdlib change looks like a non trivial amount of work, second because we use format very little, and finally because some of the usage of ppx_custom_printf
is getting replaced by the string interpolation from ppx_string
.
If someone made the stdlib support a Custom'
constructor with a more general type, I think it should be easy to extend ppx_custom_printf
to support this.
So I want to close this issue as non-actionable until someone changes the compiler. Any objection?
None from me
Would it be possible to have a way to use a pretty printing function instead of a to_string one ? It would ensure proper composition of pretty printing.