Skip to content
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

Make it easier to debug fixity issues #1060

Closed
brandonchinn178 opened this issue Aug 24, 2023 · 2 comments · Fixed by #1097
Closed

Make it easier to debug fixity issues #1060

brandonchinn178 opened this issue Aug 24, 2023 · 2 comments · Fixed by #1097

Comments

@brandonchinn178
Copy link
Collaborator

In fourmolu/fourmolu#357 (comment), it took a bit before realizing that NoImplicitPrelude is causing Prelude operators from getting the correct fixity. Is there some way we can make debugging this easier, e.g. when --debug is turned on? Perhaps when --debug is turned on, show warnings when operators from base are detected with different fixity info? I think base is an important enough package to special case this logic. Or perhaps show the warning if any operators have different fixity than in the Hackage fixity map? Since this would only show up with --debug, I think being a bit noisy with false positives is better than otherwise

@amesgen
Copy link
Member

amesgen commented Aug 24, 2023

Perhaps when --debug is turned on, show warnings when operators from base are detected with different fixity info?

This (or something similar, maybe hardcoding more "common" packages or even all packages) sounds reasonable to me, and seems to have a good power-to-weight ratio a priori.

If complexity were not an issue, it would be fancy to output an "inference path" for every operator that shows how Ormolu/Fourmolu came to chose the specific fixity.


Eventually, it would be very nice to have a more principled way to infer fixity info; but apart from relying fully on GHC (which would bring its own bag of problems, i.e. you can only format code that passes at least the renamer phase), I don't see many local improvements of the current approach 🤔

@Lucus16
Copy link

Lucus16 commented Jan 22, 2024

I'm running into this as well, I have a large code base using a custom prelude and manually writing down the fixity of each operator we use is some work, but figuring out the full list of operators we use is much harder still. It would help if there was an option that would cause ormolu to fail if it encountered an operator for which it does not know the fixity. That would make it easy to ensure we have defined all the fixities we need.

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