-
Notifications
You must be signed in to change notification settings - Fork 182
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
Consistent formatting of module types #2395
Open
Julow
wants to merge
29
commits into
ocaml-ppx:main
Choose a base branch
from
Julow:rewrite-fmt-mt
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
These attributes are always formatted in short form and are never trailing.
The module type is hard to read on the right of a module argument, which can grow complex.
In the case where arguments are docked too, also dock `Pmty_ident` and some forms of `Pmty_with` to avoid lines with just `end`.
Julow
commented
Jul 6, 2023
gpetiot
reviewed
Jul 13, 2023
Are there regressions blocking this PR? or just the merge? Because the output looks like a net improvement and I would really like to have it merged! |
I would like to review the diff one more time. Since #2440, I plan to not dock empty signatures to avoid breaking the margin. There's also diffs like that, where I would like to get the community's opinion: (** Lift a set to a powerset domain ordered by subset. The elements of the set should be drawn from
a *finite* collection of possible values, since the widening operator here is just union. *)
-module FiniteSet (Element : PrettyPrintable.PrintableOrderedType) :
- FiniteSetS with type elt = Element.t
+module FiniteSet (Element : PrettyPrintable.PrintableOrderedType) : FiniteSetS
+ with type elt = Element.t -module type Make = functor (TransferFunctions : TransferFunctions.SIL) ->
- S with module TransferFunctions = TransferFunctions
+module type Make = functor (TransferFunctions : TransferFunctions.SIL) -> S
+ with module TransferFunctions = TransferFunctions test_branch finds a few bugs like this: diff --git a/test/helpers/test_container.mli b/test/helpers/test_container.mli
index 6dbab81..648c1b1 100644
--- a/test/helpers/test_container.mli
+++ b/test/helpers/test_container.mli
@@ -7,7 +7,8 @@ module Test_S1_allow_skipping_tests (Container : sig
include Container.S1 with type 'a t := 'a t
val of_list : 'a list -> [ `Ok of 'a t | `Skip_test ]
-end) : sig
+end) :
+ sig
type 'a t [@@deriving sexp]
include Generic with type ('a, _) t := 'a t |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR refactors the function for formatting module types. It doesn't use the
block
concept, which is hard to work with and brings bugs that are too hard to solve.The new function is based on the proven model of
~box ~pro ~epi
. The output is much easier to tweak and generally more consistent.This affects module declarations too.
Some changes are considered bug fixes:
with
constraints. Spotted in Upgrade to ocamlformat 0.26.0 mirage/irmin#2262 (comment)This PR is not pure refactoring but also bring changes to be discussed:
with type
into the previous line. Thewith
-constraints are less indented.This can be ambiguous and might require breaking before a
struct
:module M ...
andmodule type T = functor ...
.