Skip to content

Avoid setting Ormolu dev flag in Cabal config#139

Merged
brandonchinn178 merged 3 commits intomasterfrom
ormolu-dev-flag
Jan 24, 2022
Merged

Avoid setting Ormolu dev flag in Cabal config#139
brandonchinn178 merged 3 commits intomasterfrom
ormolu-dev-flag

Conversation

@georgefst
Copy link
Collaborator

Carrying on the conversation from #129 (comment):

I actually intentionally want -Werror on in local development. If it's gonna fail in CI, why not have it fail locally? cabal.project also has it nominally on (although it should be updated to fourmolu +dev instead of ormolu +dev), so I'd rather we change it so both Stack and Cabal have -Werror on in local development

I've never personally understood the desire to enable -Werror, other than when one wants to ensure that builds output a non-zero exit code in the presence of warnings, e.g. in CI. During interactive development, surely it's often useful to run code that contains potentially-harmless issues like unused variables, or missing type signatures? I feel like I must be missing something.

Anyway, while this PR doesn't really change anything, it draws attention to the fact that we enable -Werror when building with Stack, but not Cabal, which is weird.

@georgefst
Copy link
Collaborator Author

I've just noticed while writing the above that #138 takes the opposite approach and sets fourmolu +dev. This would frustrate my local workflow.

@georgefst georgefst mentioned this pull request Nov 30, 2021
@brandonchinn178
Copy link
Collaborator

My preference would be to turn on the dev flag in both cabal.project and stack.yaml. You could always turn it off ad-hoc with --ghc-options -Wwarn, but I think enabling it by default is a Good Thing.

@brandonchinn178
Copy link
Collaborator

Personally, I would be very frustrated that a working build locally with default settings fails on CI. I expect a passing git clone + stack test locally should pass CI

@georgefst
Copy link
Collaborator Author

I expect a passing git clone + stack test locally should pass CI

Ah. Well I wouldn't, in the same way that I wouldn't expect running stack test to check for HLint warnings, or bad formatting.

@brandonchinn178
Copy link
Collaborator

🤷 ok, up to you. You can remove -Werror from all the stack.yaml files, then.

@georgefst
Copy link
Collaborator Author

shrug ok, up to you. You can remove -Werror from all the stack.yaml files, then.

I think I'll have to, sorry. Is it easy enough to re-enable locally to get the behaviour you want (I'm not very familiar with Stack)?

Perhaps it's worth starting an r/haskell thread or similar to find out what other people do here, and why. In my other projects, including at work, -Werror has only ever been enabled on CI.

@georgefst
Copy link
Collaborator Author

georgefst commented Nov 30, 2021

The right course of action in that case would actually be to remove all references to -Werror in fourmolu.cabal, rather than removing the dev flag. Which also avoids merge conflicts with #138.

@brandonchinn178
Copy link
Collaborator

brandonchinn178 commented Nov 30, 2021

I think I'll have to, sorry. Is it easy enough to re-enable locally to get the behaviour you want (I'm not very familiar with Stack)?

It's easy either way. To turn it on, you just add --ghc-options -Werror to your stack build command. With it turned on by default in stack.yaml, you could turn it off by adding --ghc-options -Wwarn to your stack build command. Personally, I like turning it on by default because it's easier to forget to turn on than turn off.

(My other argument is also that Ormolu devs turn on the dev flag locally by default, so why not do the same?)

The right course of action in that case would actually be to remove all references to -Werror in fourmolu.cabal, rather than removing the dev flag. Which also avoids merge conflicts with #138.

No, -Werror in fourmolu.cabal is always behind the dev flag, so there's no point keeping it in. Plus, removing it in three locations in fourmolu.cabal increase the likelihood of merge conflicts than just removing the line in cabal.project (plus, fourmolu.cabal will be touched more often upstream than cabal.project)

Keep the change to cabal.project, don't change fourmolu.cabal, and remove -Werror from the stack*.yaml files. I already updated #138 to avoid conflicts with whatever happens in this PR

@georgefst
Copy link
Collaborator Author

No, -Werror in fourmolu.cabal is always behind the dev flag, so there's no point keeping it in. Plus, removing it in three locations in fourmolu.cabal increase the likelihood of merge conflicts than just removing the line in cabal.project (plus, fourmolu.cabal will be touched more often upstream than cabal.project)

Well, on the other hand, for the sake of argument:

  • We'd then miss out on some extra warnings (but admittedly nothing terribly important - -Wincomplete-uni-patterns is even on by default since GHC 9.2, although somehow this didn't make it in to the release notes...)
  • Those lines are unlikely to change at all often.

But I don't really care much either way, so I'll do it your way!

@brandonchinn178
Copy link
Collaborator

Well either way, we'll need to make sure to add the dev flag on CI

georgefst and others added 2 commits January 23, 2022 18:59
We've inherited it from upstream, but it has no effect here, since we're not building Ormolu.
@brandonchinn178
Copy link
Collaborator

Rebase against master and resolved comments according to discussion:

  • Keep dev flag + -Werror off by default with both cabal and stack
  • Keep dev flag + -Werror in cabal file (avoids conflicts with upstream)
  • Add dev flag + -Werror to CI

To reiterate, I personally think dev/Werror should be on by default, since it's easy to turn off if you make changes and want to temporarily turn off warnings (both cabal + stack support --ghc-options=-Wwarn to the build command), and it's easier to remember to turn off errors than to remember to turn them on. But I'd much rather we merge something than leave things as-is, hence the changes above.

To try to reduce number of open PRs, I'm merging this as soon as CI passes. If changes are desired, we can open up another PR.

@brandonchinn178 brandonchinn178 merged commit e2aba95 into master Jan 24, 2022
@brandonchinn178 brandonchinn178 deleted the ormolu-dev-flag branch January 24, 2022 03:30
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.

2 participants