Reply to comment

Answer to "why the formatter decide to add a new line"

I have just came across the same problem and decided to understand what was the problem.

I think it is related to boxes. If you don't open your own toplevel box, the Format module just don't know what to do.

Compare:

# Format.fprintf fmt "%a" (pp_list ~sep:"," pp_cell) ["aa";"bb";"cc"];;
aa,bb,
cc- : unit = ()

where the last "cc" is misplaced, to

# Format.fprintf fmt "@[%a@]" (pp_list ~sep:"," pp_cell) ["aa";"bb";"cc"];;
aa,bb,cc- : unit = ()

where you get what you expect.

To my mind, you can solve the problem by opening your own toplevel box (i.e. @[ ... @]).

Reply

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
k
4
F
m
V
E
Enter the code without spaces and pay attention to upper/lower case.