Giter VIP home page Giter VIP logo

Comments (9)

johnynek avatar johnynek commented on June 12, 2024 1

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.

from algebird.

tovbinm avatar tovbinm commented on June 12, 2024

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

from algebird.

johnynek avatar johnynek commented on June 12, 2024

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 Monoid._? I wonder if you are setting up a conflicting implicit and scala just silently fails when two implicits can be found.

from algebird.

tovbinm avatar tovbinm commented on June 12, 2024

The Monoid._ is mainly needed because of the ArrayMonoid

from algebird.

tovbinm avatar tovbinm commented on June 12, 2024

Here you go - tovbinm@776cfe1

from algebird.

tovbinm avatar tovbinm commented on June 12, 2024

Also, I think I found what's the problem - import order matters (at least in the test):
This would fail:

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.

from algebird.

tovbinm avatar tovbinm commented on June 12, 2024

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

from algebird.

johnynek avatar johnynek commented on June 12, 2024

from algebird.

tovbinm avatar tovbinm commented on June 12, 2024

Well, it assumes String in + operator then:

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

from algebird.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.