Ocamlformat poll for `-> begin`

In the latest ocamlformat, there is a “shortcut” formatting for for begin end:

begin match ... with
| ... -> ...
end

instead of

begin
  match ... with
  | ... -> ...
end

That was a clear improvement, but it overwritten when there is a nested match - beginend - match:

match ... with
| ... -> begin
    match ... with
    | ...
  end

Do you think this should get changed to use the shortcut syntax when it can :

match ... with
| ... ->
    begin match ... with
    | ...
    end

Its also going to after other “shortcut” nodes, like begin function and others.

I think this is better, and I have opened a PR for it, but this its going to create diffs in the projects of users, we wanted to get everyone’s opinion.

  • Yes, its a good change
  • No, current formatting is better
  • I don’t care either way
0 voters

I don’t know the answer but the quirks around match, if, @@ and top-level expressions have been making me reconsider using Reason for the last few weeks. I’ve been keeping an eye on ocamlformat changes like begin match (which I really like!) but it feels like we’ll never reach a clean outcome. The more I learn OCaml the more I end up filling all code with begin/end.

Yeah, I would like it better if a lot of the syntax had mandatory end like match x with a -> b end

Not something thats really possible to change