Add configuration options for sorting deriving clauses and types#434
Add configuration options for sorting deriving clauses and types#434brandonchinn178 merged 1 commit intofourmolu:mainfrom
Conversation
|
👋 @michaelpj Reviewer: Please verify the following things have been done, if applicable.
|
| let sortedDeriving = if sortDeriving then sortOn (derivingStrategyKey . fmap unLoc . deriv_clause_strategy . unLoc) dd_derivs else dd_derivs | ||
| inci $ sep newline (located' p_hsDerivingClause) sortedDeriving | ||
| where | ||
| derivingStrategyKey Nothing = ClauseNoStrategy |
There was a problem hiding this comment.
I considered just sorting on showOutputable again, but that gives an order that's a bit different to what I've most often seen in the wild, which is what I've replicated here.
8cf97fb to
df5d033
Compare
|
Also some CI failures |
df5d033 to
ed3f554
Compare
|
CI fixed. I think mostly just up to you to make a call on what you'd like to do wrt defaults etc. Or I'm happy for you to just change it post-merge! I think I'm not super keen on the "sort unless there are comments" idea, what do you think? |
brandonchinn178
left a comment
There was a problem hiding this comment.
Update changelogs + finish the last stuff around defaults, and this should be good to go!
Changing the name to sort-derived-types is optional
georgefst
left a comment
There was a problem hiding this comment.
Unfortunately I feel quite strongly that both should be off by default.
ed3f554 to
9133d2f
Compare
|
Back to off by default. I added some tests with comments. I was able to get some weird behaviour with |
9133d2f to
5761e74
Compare
|
I also fixed some more issues in the AST comparison. I can now run this on the whole work codebase without issues. |
brandonchinn178
left a comment
There was a problem hiding this comment.
Looks good to me! @georgefst?
5761e74 to
3b42667
Compare
|
@michaelpj Can you fix lints and also rebase? I fixed CI on main |
3b42667 to
38bcfe0
Compare
|
Fixed and rebased. |
38bcfe0 to
c369a69
Compare
|
Not sure what's causing this failure. |
|
Are you both happy with this? |
|
@michaelpj Yeah, good to go. Sorry, can you try rebasing one more time? That CI failure should be fixed |
c369a69 to
4d82f83
Compare
|
Rebased on main but it still seems broken? |
|
Ok sorry, can you try one last time? 🤞 |
This adds two configuration options for sorting a) types in deriving clauses, and b) deriving clauses themselves. Fixes tweag/ormolu#968
4d82f83 to
799beb8
Compare
|
That worked! |
## Fourmolu 0.17.0.0 * Add new `import-grouping` option to group imports with grouping rules specified in configuration ([#403](fourmolu/fourmolu#403)) * Add new `sort-constraints` option to sort constraints alphabetically ([#433](fourmolu/fourmolu#433)) * Add new `sort-derived-classes` option to sort classes in deriving clauses ([#434](fourmolu/fourmolu#434)) * Add new `sort-derived-clauses` option to sort classes deriving clauses ([#434](fourmolu/fourmolu#434)) * Add new `trailing-section-operators` option to disable trailing "section" operators (those that are `infixr 0`, such as `$`) ([#444](fourmolu/fourmolu#444)) * Fix issue where `single-constraint-parens: never` would drop parentheses around implicit parameters ([#446](fourmolu/fourmolu#446)) * Fix indentation for parenthesized expressions that start off the indentation column ([#428](fourmolu/fourmolu#428)) * Allow multiline comments in indented contexts ([#65](fourmolu/fourmolu#65)) ## Fourmolu 0.16.2.0 ### Upstream changes: #### Ormolu 0.7.7.0 * Use single-line layout for parens around single-line content. [Issue 1120](tweag/ormolu#1120). * Allow function arguments to be on the same line even if the full type (with constraints and foralls) are on multiple lines. [PR 1125](tweag/ormolu#1125). ## Fourmolu 0.16.1.0 ### Upstream changes: #### Ormolu 0.7.6.0 * Fix Haddock comments on infix constructors [Issue 758](tweag/ormolu#758). * Don't require a trailing newline in `.ormolu` files. [Issue 1122](tweag/ormolu#1122). * Remove unnecessary indentation from list comprehensions. [Issue 966](tweag/ormolu#966). ## Fourmolu 0.16.0.0 * Allow specifying path to configuration file with `--config` ([#396](fourmolu/fourmolu#396)) ### Upstream changes: #### Ormolu 0.7.5.0 * Switched to `ghc-lib-parser-9.10`, with the following new syntactic features/behaviors: * GHC proposal [#575](https://github.com/ghc-proposals/ghc-proposals/blob/10290a668608d608c3f6c6010be265cf7a02e1fc/proposals/0575-deprecated-instances.rst): deprecated instances. * GHC proposal [#281](https://github.com/ghc-proposals/ghc-proposals/blob/10290a668608d608c3f6c6010be265cf7a02e1fc/proposals/0281-visible-forall.rst): visible forall in types of terms. Enabled by `RequiredTypeArguments` (enabled by default). * `LinearTypes`: `let` and `where` bindings can now be linear, in particular have multiplicity annotations. * Using `forall` as an identifier is now a parse error. * GHC proposal [#65](https://github.com/ghc-proposals/ghc-proposals/blob/10290a668608d608c3f6c6010be265cf7a02e1fc/proposals/0065-type-infix.rst): namespacing fixity declarations for type names and WARNING/DEPRECATED pragmas. * `TypeAbstractions` now supports `@`-binders in lambdas and function equations. * Support for the `GHC2024` language. * Updated to `Cabal-syntax-3.12`.
This adds two configuration options for sorting a) types in deriving clauses, and b) deriving clauses themselves.
Fixes tweag/ormolu#968