-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Description
I noticed that NEM seems to prefer .find
on Foldable rather on the concrete type when cats.implicits._
or more concretely import cats.instances.int._
is in scope. This confused me since I had everything working, I pulled in cats.implicits._ for some other reason and this broke the compile. What is the expected order of preference here?
object TreeWithCatsImplicit extends App {
import cats.data.NonEmptyMap
import cats.implicits._ // import cats.instances.int._
val nem: NonEmptyMap[Int, String] = NonEmptyMap.of(
1 -> "one",
2 -> "two"
)
{
import scala.reflect.runtime.universe.{reify, show}
println(show(reify { nem.find(_ == "one") }.tree))
}
// implicits.toFoldableOps(Test.this.nem)(NonEmptyMapImpl.catsDataInstancesForNonEmptyMap(implicits.catsKernelStdOrderForInt)).find(((x$1) => x$1.$eq$eq("one")))
}
object WithCatsImplicit extends App {
import cats.data.NonEmptyMap
import cats.implicits._
val nem: NonEmptyMap[Int, String] = NonEmptyMap.of(
1 -> "one",
2 -> "two"
)
println(nem.find(_ == "one"))
// Some(one)
}
object WithoutCatsImplicit extends App {
import cats.data.NonEmptyMap
import cats.kernel.Order
implicit val order: Order[Int] = Order.fromOrdering
val nem: NonEmptyMap[Int, String] = NonEmptyMap.of(
1 -> "one",
2 -> "two"
)
println(nem.find(_ == "one"))
//Some((1,one))
}
scala version 2.13
cats version 2.0.0
Metadata
Metadata
Assignees
Labels
No labels