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

Rewrite rules for sequence_, traverse_ and their counterparts #209

Open
satorg opened this issue Jan 22, 2025 · 2 comments
Open

Rewrite rules for sequence_, traverse_ and their counterparts #209

satorg opened this issue Jan 22, 2025 · 2 comments
Labels
question Further information is requested

Comments

@satorg
Copy link

satorg commented Jan 22, 2025

Since Cats v2.13.0 the following rewrites can be recommended:

  • sequence_ -> sequenceVoid
  • traverse_ -> traverseVoid
  • nonEmptySequence_ -> nonEmptySequenceVoid
  • nonEmptyTraverse_ -> nonEmptyTraverseVoid
  • parSequence_ -> parSequenceVoid
  • parTraverse_ -> parTraverseVoid
  • parNonEmptySequence_ -> parNonEmptySequenceVoid
  • parNonEmptyTraverse_ -> parNonEmptyTraverseVoid

See typelevel/cats#4611 and typelevel/cats#4682 for more details.

@satorg
Copy link
Author

satorg commented Jan 22, 2025

A question...
Should the rule only emit warnings and suggest users do the renames themselves or do the renames on behalf of the users? As I can see, the MapSequence rule does the warnings job only:

class MapSequence extends SemanticRule("TypelevelMapSequence") {

@satorg satorg added the question Further information is requested label Jan 22, 2025
@armanbilge
Copy link
Member

I think this one has good potential to be a rewrite, because it's fairly straightforward. The goal is that code that compiled before the rewrite will still compile/behave the same after the rewrite.

For some rules, that's a little more fuzzy. For example, rewriting map(_ => x) to as(x) behaves differently if x is lazy (theoretically not important for correctness, but possibly has performance implications).

If you account for people writing non-RT code, then it gets even murkier. For example, map+ sequence is a workaround for typelevel/cats#4176, so auto-rewriting that to traverse may not be what they want.

Maybe rewrites are overall still most useful, and people can use inline-comments to suppress the scalafix as a form of documentation that they are in one of these special cases. 🤷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants