-
Notifications
You must be signed in to change notification settings - Fork 409
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
Preview: Upgrade to OCamlformat 0.27.0-preview1 (unreleased) #11059
base: main
Are you sure you want to change the base?
Conversation
The aim of this preview is to gather feedback. Changelog can be found here: https://github.com/ocaml-ppx/ocamlformat/blob/main/CHANGES.md Signed-off-by: Jules Aguillon <[email protected]>
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 haven't looked through all (obviously and also sensibly because the changes are often of the same type), but here's my observations. I think some of them are solid improvements, some of them could be improved still.
@@ -6,41 +6,41 @@ open Stdune | |||
[unzip] functions which make serialisation easier. *) | |||
type ('float, 'int) t = | |||
{ elapsed_time : 'float | |||
(** Real time elapsed since the process started and the process | |||
(** Real time elapsed since the process started and the process |
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 like that the comments beginnings are aligned with the field they're documenting.
@@ -68,17 +68,21 @@ let write_lib ~base_dir ~lib ~dune = | |||
|
|||
let write base_dir = | |||
let () = Unix.mkdir base_dir 0o777 in | |||
let dune = {| | |||
let dune = |
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.
This seems a bit wasteful.
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.
This was changed in ocaml-ppx/ocamlformat#2480 but perhaps with a different case in mind.
@dvulakh Do you have an opinion ?
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.
When formatting with --profile=janestreet
, we want to keep the new behavior (multiline delimited strings always get their own lines).
We don't mind if --profile=ocamlformat
or --profile=default
keep some multiline strings docked, though.
(fun j -> | ||
sprintf "M_%d_%d_%d_%d.f()" (library_index - 1) j mod_rows k) | ||
(count subsets_per_library)) | ||
List.map |
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 like that the function bodies are indented by two from the fun
and not from the (
in front of fun
. Seems more consistent.
; "right root", (long_path, ".") | ||
; "short paths", (short_path, short_path) | ||
; "long paths", (long_path, long_path) | ||
]]) |
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.
Much more readable, only a bit surprising where the [
starts. It is aligned with the content of the string? What if the start is {foo|
, where is the indent? I think just 2 characters from the item to which the attribute is attached would be more consistent.
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 was in fact indented by 2 starting from the opening parenthese. Here's a more intuitive indentation: ocaml-ppx/ocamlformat#2613
But because this is already changed, a better formatting is possible: ocaml-ppx/ocamlformat#2615
options | ||
({ Dune_rules.Main.contexts = _; scontexts } : Dune_rules.Main.build_system) | ||
(context : Context.t) | ||
dirs | ||
: Descr.Workspace.t Memo.t |
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.
A bit undecided on this. It's kind of nice that the arguments are not indented the same amount as the function body (as that makes them bleed together), but the return type still is which is quite inconsistent.
The aim of this preview is to gather feedback.
Changelog can be found here: https://github.com/ocaml-ppx/ocamlformat/blob/main/CHANGES.md