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

Sort constraint tuples #1138

Closed
michaelpj opened this issue Oct 5, 2024 · 3 comments
Closed

Sort constraint tuples #1138

michaelpj opened this issue Oct 5, 2024 · 3 comments
Labels
style Nitpicking and things related to purely visual aspect for formatting.

Comments

@michaelpj
Copy link
Contributor

I raised this issue on fourmolu since I expected it wouldn't be something that ormolu wants to do, as it's probably too opinionated, but I thought I should raise it here to just check. Repeating the text here for simplicity.


I think I would like the option to have constraint tuples sorted. The issue is that in code which has a lot of constraints, you often have similar or identical constraint tuples that look quite different due to irrelevant differences in the order. If they were sorted it would make it easier to see the similarities or differences.

To put it another way, at the moment I have to manually make an arbitrary decision about where to add a constraint into a constraint tuple. In such a situation where it is arbitrary I think it's arguable that the formatter should decide, like for imports.

e.g. (before)

doAtThing ::
  (IOE :> es, Concurrent :> es, SomethingElse :> es, EvenMore :> es, ThatsRightMore :> es, IsThisTooMuch :> es) =>
  Args ->
  Eff es ()

vs (after)

doAtThing ::
  (Concurrent :> es, EvenMore :> es, IsThisTooMuch :> es, IOE :> es, SomethingElse :> es, ThatsRightMore :> es) =>
  Args ->
  Eff es ()

Note that even if you used this option you could still group sets of constraints together if you want to by using multiple =>s.

If we did this I'd want it to apply everywhere we have constraint tuples.

@amesgen amesgen added the style Nitpicking and things related to purely visual aspect for formatting. label Oct 5, 2024
@amesgen
Copy link
Member

amesgen commented Oct 5, 2024

Thanks, I definitely also wanted certain things to automatically be sorted in the past. Related tickets are #968 and #996.

@michaelpj
Copy link
Contributor Author

Okay. It sounds like there isn't an easy answer to "what to do about comments", which I think makes this a good candidate for inclusion in fourmolu where it can be opt-in.

@michaelpj
Copy link
Contributor Author

This got implemented in fourmolu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
style Nitpicking and things related to purely visual aspect for formatting.
Projects
None yet
Development

No branches or pull requests

2 participants