-
Notifications
You must be signed in to change notification settings - Fork 83
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
Style regression with backticks #907
Comments
Using the Quoting this Stack Overflow answer, quoting the Haskell 98 report:
Perhaps for an ordinary identifier enclosed in grave accents with no fixity declaration, ormolu should infer |
We initially decided to stick to "unknown fixity" for any operator that is not in the knowledge base. So that the formatting would look as neutral as possible (which means, everything on its own line with no differentiated indentation) when we don't have enough info. According to the haskell 98 report,
So we would probably need to do the change for both text and symbolic operators. But that would force every programmer who introduces a new operator with a fixity different than I don't know what is the good call to make here, but I see that @mrkkrp self-assigned this issue, so he will probably have better insight on this than me :) |
@mrkkrp Sure, but the haskell report states that backticked operators are no different from "symbolic" operators when it comes to default fixity. So, if we decide against the "neutral when no explicit fixity declaration is present" idea I had originally (which I'm completely OK with), maybe we should do it uniformly? |
I see now. I somehow assumed (given the quote above by @jonathanlking) that only backticked operators are inferred to be |
Perhaps it could make sense to default to |
I'd actually forgotten that backticked operators could have fixity declarations. It's possible that the title should be:
|
If their fixity is unknown, we use
in my comment above.
I don't remember, are we parsing the fixity declarations from the source file being formatted at the moment @mrkkrp? |
No, we do not. |
So at the moment, we can't know whether or not user-defined operators have a fixity decl |
Yes, that's true. I guess the question here is: is the current formatting better or worse then assuming |
I have no opinion on this. A better solution, in theory at least, might be to deduce fixity from the input: from this:
where A, B, C are known operators, and U is unknown, we could deduce that precedence(U) >= precedence(A, B, C). |
Mixing backtick-ed functions with ordinary infix operators often looks worse than it used to. This is presumably a victim of the fixity overhaul.
Ormolu 0.4:
Ormolu 0.5:
The text was updated successfully, but these errors were encountered: