Skip to content

Introduce fourmolu #1500

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Introduce fourmolu #1500

wants to merge 5 commits into from

Conversation

geo2a
Copy link
Contributor

@geo2a geo2a commented May 9, 2025

Fixes #1499

PR description

This PR introduces fourmolu as an automatic code formatter to replace stylish-haskell

Beyond the actual reformatting, I've introduced the following changes:

  • add fourmolu to the Nix shell
  • add the scripts/ci/run-fourmolu.sh scripts, which is based on the previously used script for stylish-haskell
  • add a Hydra job to check the project with fourmolu (and pushed a dummy commit to check that the CI rejects improperly styled code)
  • add The Big Reformatting Commit to .git-blame-ignore-revs and checked that the blame interface on GitHub respects it
  • with a somewhat heavy heart, butchered the style guide. The layout-related sections are removed as the layout is now enforced by fourmolu.

Additionally, I've enabled ImportQualifiedPost in all cabal files, alongside with the -Wprepositive-qualified-module warning. This extension and warning could be removed once (if?) we transition to GHC2021 as the default language.

@geo2a geo2a force-pushed the geo2a/issue-1499-introduce-fourmolu branch 4 times, most recently from f02fd29 to bcd85b6 Compare May 9, 2025 12:05
@geo2a geo2a force-pushed the geo2a/issue-1499-introduce-fourmolu branch 7 times, most recently from 8b917de to 3d236c7 Compare May 13, 2025 08:21
@geo2a geo2a marked this pull request as ready for review May 13, 2025 08:24
@@ -0,0 +1,6 @@
indentation: 2
column-limit: 100
Copy link
Member

Choose a reason for hiding this comment

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

Enforcing a column limit has various idempotency issues. Usually minor, so no need to do sth immediately, but something to keep in mind if it gets too annoying.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would you rather suggest to reformat the code base and to not enforce the limit? I do not see how we would be able to prevent addition of longer lines in this case.

Copy link
Member

Choose a reason for hiding this comment

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

No, what you do in this PR looks good to me, just pointing out this potential downside of column-limit, but no immediate action required.

geo2a added 4 commits May 13, 2025 13:36
- enable ImportQualifiedPost
- apply fourmolu code styler to all files
Allows ignoring code reformatting and similar changes
@geo2a geo2a force-pushed the geo2a/issue-1499-introduce-fourmolu branch from 3d236c7 to 1efcc78 Compare May 13, 2025 11:38
@geo2a geo2a force-pushed the geo2a/issue-1499-introduce-fourmolu branch from 4c93d83 to 03f535a Compare May 13, 2025 13:52
Copy link
Contributor

@jasagredo jasagredo left a comment

Choose a reason for hiding this comment

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

I think the final code looks good. Just a minor remark on CONTRIBUTING but overall I am fine with the result.

@@ -203,19 +203,19 @@ and improvements are always welcome.

## Formatting the code

We use `stylish-haskell` 0.14.6.0 for Haskell code formatting.
We use `fourmolu` 0.17.0.0 for Haskell code formatting.
Copy link
Contributor

Choose a reason for hiding this comment

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

It is 0.18.0.0 in the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce automatic code formatting
3 participants