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

associative binary operators #106

Open
jamesdbrock opened this issue Nov 22, 2022 · 4 comments
Open

associative binary operators #106

jamesdbrock opened this issue Nov 22, 2022 · 4 comments

Comments

@jamesdbrock
Copy link

I feel like purs-tidy’s treatment of associative binary operators could be improved.

Screenshot from 2022-11-22 10-53-02

@garyb
Copy link
Collaborator

garyb commented Nov 22, 2022

What's the point of contention here? The way it hangs the last line after reformatting, or the style of putting operators first?

Personally I prefer the reformatted code aside from the dangle, so I don't think there's much to discuss there as it's going to be a preference thing, but if it's about avoiding the dangle when rearranging this I'd agree. If you bring that dangling expression onto the same line as the operator manually it won't reformat it to dangle, so there is room for a heuristic that will stop it from doing that when formatting existing code potentially.

@natefaubion
Copy link
Owner

Unfortunately, it's difficult to reformat it without the dangling bit because that's a common stylistic choice for the trailing operand. I couldn't come up with a local heuristic like I could for the leading operands, other than to not support the dangling operand at all. It's possible one could do some kind of larger analysis on the operator chain, but I don't really want to write that.

@jamesdbrock
Copy link
Author

Yeah I like the <> operators at the beginning of the line too.

It's the two dangles which I find distracting. There is a dangle after the first line, and a dangle before the last line.

Anyway, it seems you're already aware of this case and have thought about it and have not yet written a solution because it's not worth it the effort, so fair enough. I don't really want to write it either.

@natefaubion
Copy link
Owner

It's the two dangles which I find distracting. There is a dangle after the first line, and a dangle before the last line.

Indenting leading operators is by far the common style, and what I prefer. I don't have any intention of ever changing that as it's deliberate. If anyone wants to have a go at fixing the other, which would entail a heuristic for "correcting" a different style, I'm happy to consider it, but I also have no intention of doing it myself.

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

No branches or pull requests

3 participants