Ocamlformat: infix apply with function definition

I have opened a PR on ocamlformat that promotes a very nice formatting that was only available to users of --ocp-indent-compat:

let () =
  fooooo
  |>>>>> List.iter (fun a ->
             let x =
               some_really_really_really_long_name_that_doesn't_fit_on_the_line
               $ y
             in
             fooooooooooo x)

becomes

let () =
  fooooo
  |>>>>> List.iter (fun a ->
      let x =
        some_really_really_really_long_name_that_doesn't_fit_on_the_line $ y
      in
      fooooooooooo x)

Before, there was an indentation of 4 that was aligned with List, now there is an indentation of 4 that is aligned on |>>>>>.

Of course, such a big infix operator is quite rare in real code, with |> the indentation is only reduced by 3 (2 for |>, and one for the space after it). One of the benefits is that you now have an odd number of spaces which might be desirable depending on editor config.

Still, this is quite a large change, so I wanted to ask the community if you think its worth the diff to merge that in for everyone ?

If enough people don’t like this, we can make an option to either opt-in or out of this.

Ps: this won’t affect people using profile=janestreet, because this profile has ocp-indent-compat enabled and therefore already has this formatting.

2 Likes