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

Use alignWith in alignMergeWith #4676

Merged
merged 2 commits into from
Nov 16, 2024
Merged

Conversation

joroKr21
Copy link
Member

alignWith is usually overridden for efficiency

`alignWith` is usually overridden for efficiency
johnynek
johnynek previously approved these changes Nov 14, 2024
@satorg
Copy link
Contributor

satorg commented Nov 14, 2024

Thank you!
Would you consider adding a new law into cats.laws.AlignLaws along with a corresponding rule in AlingTests please?
Something similar to

def alignWithConsistent[A, B, C](fa: F[A], fb: F[B], f: A Ior B => C): IsEq[F[C]] =
fa.alignWith(fb)(f) <-> fa.align(fb).map(f)

satorg
satorg previously approved these changes Nov 14, 2024
@joroKr21
Copy link
Member Author

@satorg that law already exists. Am I missing something?

@satorg
Copy link
Contributor

satorg commented Nov 15, 2024

I mean, a law that would check a correspondence between alignMergeWith and alignWith.
The existing law checks alignWith <-> align.

@joroKr21
Copy link
Member Author

Done, but it seems like now unrelated tests are failing

danicheg
danicheg previously approved these changes Nov 15, 2024
Comment on lines 25 to 26
import cats.syntax.align.*
import cats.syntax.functor.*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a nit but maybe these changes to the import style are unnecessary. Although it's Scalafmt duty, we use scala213source3 dialect that allows cross-version syntax constructions to be put together.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess Scalafmt is not configured to update the imports

Copy link
Member

@danicheg danicheg Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, we have this
runner.dialectOverride.allowStarWildcardImport = false
and it appears to be not working (or maybe it works oppositely to my expectations)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danicheg , good catch btw!
I removed that line from .scalafmt.conf and got this: #4677.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah, I thought we'd like to keep the Scala 2 style :) But okay I don't strongly disagree with this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... I doesn't exactly compile for all the modules in the repo. I guess, it could be a reason why it was disabled 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted. Just keep in mind that if you let Intellij optimize imports it will replace them with star

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, the import style was configurable there.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps, I didn't check but it takes if from sbt

satorg
satorg previously approved these changes Nov 15, 2024
Copy link
Contributor

@satorg satorg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@danicheg danicheg merged commit 02bfdf7 into typelevel:main Nov 16, 2024
16 checks passed
@joroKr21 joroKr21 deleted the align-with branch November 17, 2024 08:13
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

Successfully merging this pull request may close these issues.

4 participants