Hi!
This seems to be related to the break-separators
option. It was introduced in 0.9, and even in 0.10 it did not take work for all the OCaml features. It was further expanded in https://github.com/ocaml-ppx/ocamlformat/pull/931, which seems to be causing this diff.
In 0.12 (soon released), this option has been reworked a bit to be more flexible, and the docking aspect is controlled by the new dock-collection-brackets
option.
I had a go at formatting orewa with it and tweaked a bit the config, and it looks like this (this is a very small subset of diffs but representative of the issue I think):
diff --git a/.ocamlformat b/.ocamlformat
index f191d20..1e34970 100644
--- a/.ocamlformat
+++ b/.ocamlformat
@@ -17,7 +17,9 @@ sequence-style=terminator
type-decl=sparse
wrap-fun-args=false
module-item-spacing=sparse
-break-separators=after-and-docked
+break-separators=after
+dock-collection-brackets=false
+space-around-lists=false
break-infix-before-func=false
break-collection-expressions=fit-or-vertical
exp-grouping=parens
diff --git a/src/orewa.ml b/src/orewa.ml
index f793210..a2c9941 100644
--- a/src/orewa.ml
+++ b/src/orewa.ml
@@ -262,22 +263,17 @@ let bitfield t ?overflow key ops =
let ops =
ops
|> List.map ~f:(function
- | Get (size, offset) ->
- ["GET"; string_of_intsize size; string_of_offset offset]
+ | Get (size, offset) -> ["GET"; string_of_intsize size; string_of_offset offset]
| Set (size, offset, value) ->
- [
- "SET";
+ [ "SET";
string_of_intsize size;
string_of_offset offset;
- string_of_int value;
- ]
+ string_of_int value ]
| Incrby (size, offset, increment) ->
- [
- "INCRBY";
+ [ "INCRBY";
string_of_intsize size;
string_of_offset offset;
- string_of_int increment;
- ])
+ string_of_int increment ])
|> List.concat
in
let overflow =
Now, why does ocamlformat keep changing your code? Put simply, it is pretty hard to find all the interactions between different options - sometimes we find weird interactions between options, and the configuration space is pretty large.
So while 1.0 is not out, we allow changing behaviour when it improves the output: but one’s fix can be another one’s regression, unfortunately. But it seems that we’re making progress!
Anyway, thanks for using ocamlformat
and reporting this issue - even though ocamlformat is a couple years old it’s still very much for early adopters so it’s important to get feedback! 