Skip to content
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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Julow
Copy link
Contributor

@Julow Julow commented Oct 30, 2024

The aim of this preview is to gather feedback.

Changelog can be found here: https://github.com/ocaml-ppx/ocamlformat/blob/main/CHANGES.md

Copy link
Collaborator

@Leonidas-from-XIV Leonidas-from-XIV left a 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.

bin/describe/describe_workspace.ml Outdated Show resolved Hide resolved
@@ -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
Copy link
Collaborator

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 =
Copy link
Collaborator

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.

Copy link
Contributor Author

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 ?

Copy link

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
Copy link
Collaborator

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)
]])
Copy link
Collaborator

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.

Copy link
Contributor Author

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
Copy link
Collaborator

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

Signed-off-by: Jules Aguillon <[email protected]>
@Julow Julow force-pushed the preview-ocamlformat-0.27.0-preview1 branch from 23067cb to 9b8527b Compare November 28, 2024 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants