Skip to content
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

combine syntax appears to be behaving unexpectedly when kitchen sink importing #763

Closed
longcao opened this issue Dec 17, 2015 · 6 comments
Closed
Assignees

Comments

@longcao
Copy link
Contributor

longcao commented Dec 17, 2015

combine and |+| are listed as aliases for one another but when using the kitchen sink imports, they appear to be routing to an unexpected implementation:

import cats.std.all._
import cats.syntax.all._

scala> Option("asdf") combine Option("qwer") 
res0: Option[String] = Some(asdf)

scala> Option("asdf") |+| Option("qwer") 
res1: Option[String] = Some(asdfqwer)

scala> scala.reflect.runtime.universe.reify { Option("asdf") |+| Option("qwer") }
res2: reflect.runtime.universe.Expr[Option[String]] = Expr[scala.Option[java.lang.String]](`package`.all.semigroupSyntax(Option.apply("asdf"))(`package`.all.optionMonoid(`package`.all.stringMonoid)).$bar$plus$bar(Option.apply("qwer")))

scala> scala.reflect.runtime.universe.reify { Option("asdf") combine Option("qwer") }
res3: reflect.runtime.universe.Expr[Option[String]] = Expr[scala.Option[java.lang.String]](`package`.all.toSemigroupKOps(Option.apply("asdf"))(`package`.all.optionInstance).combine(Option.apply("qwer")))

For now, I've decided to work around this by importing a bit more strictly down to what I want:

import cats.std.all._
import cats.syntax.semigroup._

scala> Option("asdf") combine Option("qwer")
res0: Option[String] = Some(asdfqwer)
@ceedubs
Copy link
Contributor

ceedubs commented Dec 17, 2015

here is a relevant gitter conversation

@ceedubs
Copy link
Contributor

ceedubs commented Dec 17, 2015

My initial reaction to this is that we should probably rename the combine on SemigroupK to combineK or something to avoid ambiguity. Separately, I think that I think that the Semigroup[Option[A]] instance should be the one derived from SemigroupK[Option] as opposed to the one derived from Semigroup[A]. This has been discussed before, but I can't recall what everyone thought. FWIW I believe this is what Idris does.

@milessabin
Copy link
Member

This is going to be an issue for Monoid and MonoidK as well, right?

@milessabin
Copy link
Member

And probably Alternative. See also #757.

@ceedubs
Copy link
Contributor

ceedubs commented Dec 18, 2015

I started putting together a PR for this, but I think that any change for this is going to run into conflicts with #757, so maybe we should hold on this until that one is merged.

@milessabin
Copy link
Member

Or incorporate your changes into that?

ceedubs added a commit to ceedubs/cats that referenced this issue Jan 6, 2016
@ceedubs ceedubs self-assigned this Jan 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants