-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Make convert
available without import
#11786
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
Conversation
given Conversion[String, Int] = _.length | ||
given Conversion[Int, String] = _.toString | ||
|
||
def f(x: String): Int = x.convert | ||
def g(x: Int): String = x.convert[String] | ||
def g(x: Int): String = x.convert |
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.
This won't work if there are two Conversion[Int, Y]
in scope for two different Y
s.
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.
It does with a suitable type ascription, see updated test.
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.
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.
Yes, apparently it works, indeed.
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 think this better than what we had.
given Conversion[String, Int] = _.length | ||
given Conversion[Int, String] = _.toString | ||
|
||
def f(x: String): Int = x.convert | ||
def g(x: Int): String = x.convert[String] | ||
def g(x: Int): String = x.convert |
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.
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.
Changing the name to ~
is a different battle, and should definitely not be part of this PR.
bec8412
to
ddd7449
Compare
No description provided.