-
Notifications
You must be signed in to change notification settings - Fork 399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade to ocamlformat 0.26.0 #8064
Conversation
Once 3.9.0 is out I'll upgrade to 0.25.0 first so we can see what's going on more precisely (I'll also enable |
src/dune_rules/dune_env.ml
Outdated
@@ -232,8 +233,9 @@ module Stanza = struct | |||
enter | |||
(let+ pat = | |||
keyword "_" >>> return Any | |||
<|> let+ p = Profile.decode in | |||
Profile p | |||
<|> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO the old code looked better here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of the similar change in cmd code, where the let-expression is much bigger and the operators are not chained ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old version is better there too. The additional line only pays off when the let expression has some ugly wrapping due to the lack of horizontal space. There was no such issue there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can ocamlformat pick the one that causes the least wrapping? (at least under the hood)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really, OCamlformat cannot compare two possible formatting. Only the input can be considered (though, multiple iterations on the whole code can be made).
But it can format differently whether there would be no wrapping at all and it can detect chained operators.
Such formatting could be possible:
<|> let+ p = Profile.decode in Profile p
<|> ...
falling back to this as soon as it doesn't fit on the line:
<|>
let+ p = Profile.decode in
(* longer code *)
Profile p
<|> ...
I'm mentioning chained operators because to me, the cmd code looks better with less indentation.
To me, that indentation can cause ugly wrapping means that it does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By looking at the diff again, I find that the reduced indentation do save lines by removing some wrapping. I also do not find a lot of chained operators so my previous suggestion is not valid.
Though, it should be possible have this formatting, as long as it fits on one line:
...
<|> let+ p = Profile.decode in Profile p
Should I add this before the next release ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a huge fan of saving lines at all cost, I think that the old version was better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went back and found the reason for this change: ocaml-ppx/ocamlformat#2315
It's a consistency change, in the previous version, the line was broken on regular lets but not letops:
let _ =
Cmd.v info
@@ let+ trimmed_size = () in
()
let _ =
()
<|> let+ p = Profile.decode in
Profile p
let _ =
Cmd.v info
@@
let trimmed_size = () in
()
let _ =
()
<|>
let p = Profile.decode in
Profile p
The other form exists in the code: bin/describe/describe_workspace.ml
line 378.
This diff can go away by keeping the line break from the source code, whether it's a let or a letop. (ocaml-ppx/ocamlformat#2396)
We try to add as few of these as possible but the regression is large enough to justify it.
I'll merge this patch and update this preview PR after the weekend.
Let me know and I'll rebase this. |
you can go ahead! |
a17d7ed
to
15583f7
Compare
I rebased and re-ran the preview with the |
.git-blame-ignore-revs
Outdated
@@ -1,2 +1,4 @@ | |||
# ocamlformat 0.25.1 | |||
3f01f6f3694e48cb1868018121f3959f8d23baca | |||
# Upgrade to OCamlformat 0.26.0 | |||
8a1a919e3895787ae3781da1d6aff4cc41ce04c3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to do that in this PR since this will change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right!
I'll make sure to remove that and fix the version line before I mark the PR as ready.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though, do you think this PR could be merged unsquashed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for now I prefer doing this in 2 steps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok!
15583f7
to
96f2092
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, these are all improvements. Let's wait for @rgrinberg's opinion as well.
Thanks :) Unless a problem is found, I intent to release today. |
96f2092
to
272a7b1
Compare
OCamlformat 0.26.0 has been released! This PR can be merged or closed if it's a bit too early to upgrade. |
272a7b1
to
b3a1db3
Compare
b3a1db3
to
400356c
Compare
I rebased this; this can land once #8311 is merged. |
Signed-off-by: Jules Aguillon <jules@j3s.fr> Signed-off-by: Etienne Millon <me@emillon.org>
400356c
to
a18c6fc
Compare
~compare:(fun | ||
(x : _ Install.Entry.t) (y : _ Install.Entry.t) -> | ||
Path.compare x.src y.src) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation here is kind of funny. Is this expected @Julow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is expected: The ->
was moved to the same line as the arguments to avoid the previous indentation. The arguments no longer fit on the line and have to break.
The arguments are indented more than the body for disambiguation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a non-blocking comment.
The changed formatting of
@@ let ...
(any operator) cause huge diffs in the command descriptions. The changed indentation ofif
andlet
in parentheses also has a big impact.The aim of this commit is to gather feedback.
Changelog can be found here: https://github.com/ocaml-ppx/ocamlformat/blob/main/CHANGES.md