-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add CanEqual typeclass instances of Option, Either and Tuple for strictEquality #12419
Merged
dwijnand
merged 1 commit into
scala:master
from
kevin-lee:add-CanEqual-typeclass-instances-for-Option-Either-Tuple
Aug 19, 2021
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this can only be added in 3.1. Not sure if we can use
@experimnetal
here because the users will no have the choice to use it or not.@sjrd @smarter WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. This must be for 3.1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @nicolasstucki and @sjrd for your answers. I have a few questions. I'm so sorry to ask it when everyone is busy with finalizing Scala 3 for release and I really appreciate your answer.
Regarding the users having no choice once it's added, could you please think about who are affected by this?
They are the ones who actually need
strictEquality
and most likely need this typeclass instance. The ones don't usestrictEquality
are not affected at all. Besides, the users do still have contol ofCanEqual[T, U]
since it's not auto-magically give themCanEqual[T, U]
as well.Can there be another use case than this one? I think it would be hard to find any other use case of
CanEqual
forOption
but I know that I could be easily wrong so I'm happy to take any advice.If what I mentioned above is not so important, that's fine. Could you tell me about the rest please?
a. Can we have the other
CanEqual
forOption
to solvecannot be compared with == or !=
onNone
case in pattern matching?b. Can we have
CanEqual
forEither
?c. Can we have
CanEqual
forTuple
?It will be so nice if at least the ones for
Tuple
are accepted for3.0
because it's so common use case.Finally, could you please think about what would make
strictEquality
usable and more useful. Whenever users useOption
,Either
andTuple
, they need to import their ownCanEqual
typeclass instances seprately and it would be so annoying.As far as I know, wildcard import like
import my.typeclasses._
doesn't work and it has to be done seprately like.Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I just found that
3.0.0
has been tagged already. 😅There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding,
I didn't know that I could do
import my.typeclasses.given
for that. Sorry about lack of my Scala 3 knowledge. 😅