-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Tuple2 implicits do not work with Arrays #661
Comments
In fact, same happens with simple tuples as well: import com.twitter.algebird.Monoid._
import com.twitter.algebird.Operators._
val x = 1 -> 1
x + x // fails to compile |
Huh. This is very strange. Can you make a PR with a test to demonstrate the failure. We use tuples with Semigroups all the time. Why are you importing |
The |
Here you go - tovbinm@776cfe1 |
Also, I think I found what's the problem - import order matters (at least in the test): import com.twitter.algebird.Monoid._
import com.twitter.algebird.Operators._ This works: import com.twitter.algebird.Operators._
import com.twitter.algebird.Monoid._ But in my project import order does not matter, so the problem persists. |
Here is the failure again in Ammonite: Welcome to the Ammonite Repl 1.1.0
(Scala 2.12.4 Java 1.8.0_131)
If you like Ammonite, please support our development at www.patreon.com/lihaoyi
@ import $ivy.`com.twitter::algebird-core:0.13.4`
import $ivy.$
@ import com.twitter.algebird.Operators._
import com.twitter.algebird.Operators._
@ import com.twitter.algebird.Monoid._
import com.twitter.algebird.Monoid._
@ Array(1,2) -> Array(1,2) + Array(1,2) -> Array(1,2)
cmd3.sc:1: diverging implicit expansion for type algebra.Monoid[(Array[Int], Array[Int])]
starting with method fromAlgebraAdditiveMonoid in trait FromAlgebraMonoidImplicit1
val res3 = Array(1,2) -> Array(1,2) + Array(1,2) -> Array(1,2)
^
cmd3.sc:1: value + is not a member of (Array[Int], Array[Int])
val res3 = Array(1,2) -> Array(1,2) + Array(1,2) -> Array(1,2)
^
Compilation Failed |
But scala should search the Monoid companion. What if you don’t try the
Monoid import?
On Sun, Jul 29, 2018 at 05:45 Matthew Tovbin ***@***.***> wrote:
here is it in Ammonite:
Welcome to the Ammonite Repl 1.1.0
(Scala 2.12.4 Java 1.8.0_131)
If you like Ammonite, please support our development at www.patreon.com/lihaoyi
@ import $ivy.`com.twitter::algebird-core:0.13.4`
import $ivy.$
@ import com.twitter.algebird.Operators._
import com.twitter.algebird.Operators._
@ import com.twitter.algebird.Monoid._
import com.twitter.algebird.Monoid._
@ Array(1,2) + Array(1,1)cmd3.sc:1: diverging implicit expansion for type algebra.Monoid[Array[Int]]
starting with method fromAlgebraAdditiveMonoid in trait FromAlgebraMonoidImplicit1
val res3 = Array(1,2) + Array(1,1)
^cmd3.sc:1: value + is not a member of Array[Int]
val res3 = Array(1,2) + Array(1,1)
^
Compilation Failed
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#661 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEJdjE0u-uFH2Yt1D3JiclwQfVqsNrEks5uLdirgaJpZM4VlNdl>
.
--
P. Oscar Boykin, Ph.D. | http://twitter.com/posco | http://pobox.com/~boykin
|
Well, it assumes Welcome to the Ammonite Repl 1.1.0
(Scala 2.12.4 Java 1.8.0_131)
If you like Ammonite, please support our development at www.patreon.com/lihaoyi
@ import $ivy.`com.twitter::algebird-core:0.13.4`
import $ivy.$
@ import com.twitter.algebird._
import com.twitter.algebird._
@ import com.twitter.algebird.Operators._
import com.twitter.algebird.Operators._
@ (Array(1,2) -> Array(1,2)) + (Array(1,2) -> Array(1,2))
cmd3.sc:1: type mismatch;
found : (Array[Int], Array[Int])
required: String
val res3 = (Array(1,2) -> Array(1,2)) + (Array(1,2) -> Array(1,2))
^
Compilation Failed |
Honestly it’s not that common to use Operators with Algebird. I can look into it, but in the meantime I recommend you use Semigroup.plus on the companion. It is probably an ambiguous implicit somewhere. |
The following code fails to compile:
unless we explicitly add:
Tested with Algebird 0.13.4 and Scala 2.11.12
The text was updated successfully, but these errors were encountered: