We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
When searching for extension methods, I'm finding categories of things that don't work which involve implicit defs to summon the instances.
trait Semigroup[T] { def (lhs: T) append (rhs: T): T } object Semigroup { implicit object stringAppend extends Semigroup[String] { override def (lhs: String) append (rhs: String): String = lhs + rhs } implicit def sumSemigroup[N](implicit N: Numeric[N]): Semigroup[N] = new { override def (lhs: N) append (rhs: N): N = N.plus(lhs, rhs) } } object Main { def main(args: Array[String]): Unit = { import Semigroup.stringAppend // necessary to make the extension method visible println("Hi" append " mum") import Semigroup.sumSemigroup // this is not sufficient println(1 append 2) // this won't compile implicit val intSumAppend: Semigroup[Int] = sumSemigroup[Int] println(3 append 4) // this will } }
The text was updated successfully, but these errors were encountered:
Seems like a duplicate of #5773, which I opened yesterday 😄
Sorry, something went wrong.
Could well be.
Closing for now as duplicate; feel free to add the example to the other issue.
No branches or pull requests
Uh oh!
There was an error while loading. Please reload this page.
When searching for extension methods, I'm finding categories of things that don't work which involve implicit defs to summon the instances.
The text was updated successfully, but these errors were encountered: