Skip to content

Merge ormolu-0.4.0.0#138

Merged
georgefst merged 36 commits intomasterfrom
merge-ormolu
Jan 10, 2022
Merged

Merge ormolu-0.4.0.0#138
georgefst merged 36 commits intomasterfrom
merge-ormolu

Conversation

@brandonchinn178
Copy link
Collaborator

@brandonchinn178 brandonchinn178 commented Nov 29, 2021

Adds GHC 9.2 support to fourmolu (for free!)

Needs fixing (either in this PR or in a followup PR):

  • Fix indentation after guard
  • Fix import newline regression
  • Fix indentation after list

Comment on lines +11 to +13
| x == 6 =
foo x
+ foo 20
foo x
+ foo 20
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is due to an Ormolu fix that doesn't look good with 2-space indentation (it also didn't look good with Fourmolu's 2-space indentation). A later PR should probably edit the logic to say "if indentation is <= 2, add an indentation, otherwise, don't"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(tweag/ormolu#813)

Agreed on the fix. Perhaps we should tackle it in this PR if it's that simple? Otherwise we can open an issue, but we'll have to make sure we mark it high-priority and fix it before the next release.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're ok with it, I'd rather merge this PR asap and open a high priority issue after

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We definitely need to fix this before making a release. My inclination is to fix it before merging, rather than letting the regression hit master. Why do you feel differently?

Same goes for the stray newlines in import lists.

(I was about to push a commit reverting the outputs to what we'd hope to see, and suggest that we then fix the tests properly in this PR. But I realised that would be rude without getting your opinion first.)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was about to push a commit reverting the outputs to what we'd hope to see, and suggest that we then fix the tests properly in this PR.

See #140 instead for said changes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you feel differently?

Personally, I would prefer merging ormolu PRs to only resolve merge conflicts because of the sheer amount of changes that are being merged in. If I were to fix the stuff now, the PR diff would include both merge conflict changes (i.e. changes that are needed to merge anything at all) and "feature work" changes. Having the "feature work"/regression fixes commits be separate helps a bit, but in a PR where 20/30 commits are from upstream, the fourmolu-specific commits can get lost in the weeds.

But I don't feel too strongly. I can continue working on this branhc

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the separation is still visible as long as we don't squash-merge. I'd prefer that to breaking the main branch.

(mkT dropBlankTypeHaddocks)
hsmod
{ hsmodImports =
concat $ normalizeImports True (hsmodImports hsmod),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is new; Ormolu now automatically normalizes a module immediately after parsing. I'm forcing the parameter to normalizeImports here to True so that we can sort the imports, but not get rid of the raw grouping information so we can (optionally) print the groups separately later on depending on poRespectful

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be some error here which is leading to the unwanted blank lines in e.g. data/examples/import/sorted-four-out.hs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that makes sense to me

<> fmap getLoc con_ex_tvs
<> maybeToList (fmap getLoc con_mb_cxt)
[RealSrcSpan real Nothing | AddEpAnn AnnForall (EpaSpan real) <- epAnnAnns con_ext]
<> fmap getLocA con_ex_tvs
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the deindent here looks weird. Ormolu has it correctly indented, but running fourmolu deindents it back. A latter PR should investigate and fix

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brandonchinn178
Copy link
Collaborator Author

FYI @georgefst you'll need to go to Settings > Protected branches and edit the protection to remove 8.8 and add 9.2

@brandonchinn178
Copy link
Collaborator Author

@georgefst this is blocking the aeson-2 upgrade in stackage, do you think you can review this by January?

@georgefst
Copy link
Collaborator

Thanks for letting me know! This has been near the top of my to-do list for a while, but that's probably the kick I needed. Fortunately I've just finished work for the holidays, so I should get to this in the next few days.

@georgefst
Copy link
Collaborator

Thanks for letting me know! This has been near the top of my to-do list for a while, but that's probably the kick I needed. Fortunately I've just finished work for the holidays, so I should get to this in the next few days.

Time flies. Got terribly sidetracked by the inability to build this on GHC 8.10 (digital-asset/ghc-lib#344). I promise that barring any serious emergency I'll have this reviewed within 24 hours.

I have been using this heavily via a fork of the ghc-9.2 branch of HLS for the last week, with just one small issue around reordering imports. So that's a good sign.

Copy link
Collaborator

@georgefst georgefst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this! It's pretty thankless work and I really appreciate it.

If there are any options you'd like to see, let us know. If it's not too complicated to implement (and especially if you implement it yourself!) then we'll probably add it.

Run `cabal test` and `./format.sh` before submitting any pull requests.
See `DEVELOPER.md` for documentation.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this is no longer the right place for this.

But perhaps we should point out the option of running scripts/run-fourmolu.sh manually in DEVELOPER.md. Some people don't like pre-commit hooks.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will do

Comment on lines +5 to +6
5 -> True
_ -> False
5 -> True
_ -> False
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI reverting the change to multiple-guard-statements-four-out.hs also reverts this change. This is correct and matches Ormolu's behavior

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, ok, looks weird to me but this is definitely not to place to change it then.

@brandonchinn178
Copy link
Collaborator Author

Fixed DEVELOPER.md and the post-guard indent regression. Still working on the import regression

@brandonchinn178
Copy link
Collaborator Author

Done. Should be ready to merge

@georgefst
Copy link
Collaborator

Nice! I'm happy to merge. Any idea what's holding up CI?

Do you want to handle the release? Otherwise I can do it this evening (GMT).

@brandonchinn178
Copy link
Collaborator Author

#138 (comment)

FYI @georgefst you'll need to go to Settings > Protected branches and edit the protection to remove 8.8 and add 9.2

Feel free to handle the release

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.

5 participants