-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Currency instances #4564
base: main
Are you sure you want to change the base?
Currency instances #4564
Conversation
kernel/src/main/scala/cats/kernel/instances/CurrencyInstances.scala
Outdated
Show resolved
Hide resolved
kernel/src/main/scala-2.12/cats/kernel/compat/scalaVersionSpecific.scala
Outdated
Show resolved
Hide resolved
Is the |
Hi @massimosiani , sorry for the long reply. Looks like your PR got buried under a pile of others, although it looks pretty mature. Would you be interested to move it forward? In such a case, would you update it to the current |
Hi @satorg, of course! Thanks for the update, I'll do it ASAP. |
3c5f94f
to
58de8f0
Compare
kernel/src/main/scala-2.12/cats/kernel/compat/scalaVersionSpecific.scala
Outdated
Show resolved
Hide resolved
implicit class setExtension[A](private val s: java.util.Set[A]) extends AnyVal { | ||
def asScala: mutable.Set[A] = `set asScala`(s) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This extension method is only used for Gen.oneOf
in tests, and the latter only requires Iterable
. So I'd suggest to go with the minimally required type here as well:
implicit class setExtension[A](private val s: java.util.Set[A]) extends AnyVal { | |
def asScala: mutable.Set[A] = `set asScala`(s) | |
} | |
implicit class iterableExtension[A](private val s: java.lang.Iterable[A]) extends AnyVal { | |
def asScala: Iterable[A] = iterableAsScalaIterable(s) // assuming import scala.collection.JavaConverters._ | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides, if this extension method is for the sake of testing only, I wonder if it'd make sense to move it from "main" to "test" scope?
@@ -35,4 +37,8 @@ private[cats] object scalaVersionSpecific { | |||
implicit class iterableOnceExtension[A](private val io: IterableOnce[A]) extends AnyVal { | |||
def reduceOption(f: (A, A) => A): Option[A] = io.iterator.reduceOption(f) | |||
} | |||
|
|||
implicit class setExtension[A](private val s: java.util.Set[A]) extends AnyVal { | |||
def asScala: mutable.Set[A] = SetHasAsScala(s).asScala |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I doubt that SetHasAsScala
is a part of any API. Not mention this call can allocate a class instance without a reason. I'd probably give a shot to scala.jdk.javaapi.CollectionConverters
here, e.g.:
import scala.jdk.javaapi.CollectionConverters
...
def asScala: Iterable[A] = CollectionConverters.asScala(x)
@@ -35,4 +36,8 @@ private[cats] object scalaVersionSpecific { | |||
implicit class iterableOnceExtension[A](private val io: IterableOnce[A]) extends AnyVal { | |||
def reduceOption(f: (A, A) => A): Option[A] = io.iterator.reduceOption(f) | |||
} | |||
|
|||
implicit class setExtension[A](private val s: java.util.Set[A]) extends AnyVal { | |||
def asScala: Iterable[A] = CollectionConverters.asScala(x) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def asScala: Iterable[A] = CollectionConverters.asScala(x) | |
def asScala: Iterable[A] = CollectionConverters.asScala(s) |
e38b59e
to
15861a7
Compare
15861a7
to
1ceeb9a
Compare
Addresses #4562.
I followed the steps outlined here #3910 (comment), there's no
Currency
in scala js/native tough.