Closed Niols closed 1 month ago
Out of curiosity, how would be formatted the same examples if you changed @@ RHS
by (RHS)
? I find the fact that the content of the function isn't indented to be a bit strange, but if ocp-indent does it, I guess there's a rationale (maybe chains of @@
where you don't want to indent each function to look like JS' callback hell?)
Yes, it is rather classic in OCaml to write something like
a_function @@ fun x ->
another_function @@ fun y ->
(x + y) / 2
(and similarly with >>=
) However, it is not super obvious how to have this style and proper multi-line support. With parentheses around the right-hand side, this looks like:
foo bar baz (fun x ->
x
)
;;
foo
bar
baz
(fun x ->
x
)
Related issue: https://github.com/tweag/topiary/issues/726
As of https://github.com/tweag/topiary/commit/1720fa963fdf65e9c767edbe02132ccab4078f5a, Topiary formats:
as
The single-line one makes sense, I believe, but the multi-line one is just wrong. I do not really have a better solution, though. Tuareg/ocp-indent indent as:
and
I am thinking maybe the latter is the best way to go?
Related to https://github.com/tweag/topiary/issues/726