Ocamlformat: unexpected 4x indent for multi-line arguments

The 4x indentation is needed if the argument list must break before the fun:

let _ =
  Array.fold gear_nums_mat ~init:(larger argument_____)
    ~f:(fun init gear_nums_row ->
      Array.fold gear_nums_row ~init ~f:(fun init gear_nums ->
          match gear_nums with
          | [x; y] -> init + (x * y)
          | _ -> init
      )
  )

It would be very hard for OCamlformat to reliably indent this case while also using the 2x indentation when possible.

This is also a case where a small change in the code could cause OCamlformat to reformat a large part of it, if the 2x indentation suddenly does not apply.

1 Like