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

Enumerable (WIP) #4349

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
4 changes: 4 additions & 0 deletions kernel/src/main/scala-2.12/cats/kernel/EnumerableCompat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ package kernel
import scala.{specialized => sp}
import scala.collection.immutable.Stream

@deprecated(message = "Please use Enumerable instead.", since = "2.10.0")
trait PartialPreviousUpperBounded[@sp A] extends PartialPrevious[A] with PartialNext[A] with UpperBounded[A] {

/**
* Enumerate the members in descending order.
*/
@deprecated(message = "Please use Enumerable.membersDescending.", since = "2.10.0")
def membersDescending: Stream[A] = {
def loop(a: A): Stream[A] =
partialPrevious(a) match {
Expand All @@ -41,11 +43,13 @@ trait PartialPreviousUpperBounded[@sp A] extends PartialPrevious[A] with Partial

}

@deprecated(message = "Please use Enumerable instead.", since = "2.10.0")
trait PartialNextLowerBounded[@sp A] extends PartialPrevious[A] with PartialNext[A] with LowerBounded[A] {

/**
* Enumerate the members in ascending order.
*/
@deprecated(message = "Please use Enumerable.membersAscending.", since = "2.10.0")
def membersAscending: Stream[A] = {
def loop(a: A): Stream[A] =
partialNext(a) match {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package cats
package kernel

private[kernel] object ScalaVersionSpecificLazyListCompat extends LazyListCompatBase {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder, can we simply define a type alias Stream => LazyList for Scala 2.12,
while keeping a usual LazyList for Scala 2.13+ ?

type LazyList[a] => Stream[a]
val LazyList = Stream

or something like that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably do that, but we'd be implying that all methods used would be identical for Stream and LazyList. I think they are right now...and we could add exceptions if needed in the future...

So...yes? I'll try it out.

override final type T[A] = scala.collection.immutable.Stream[A]

override final def apply[A](a: A*): T[A] =
scala.collection.immutable.Stream.apply[A](a: _*)
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ package kernel
import scala.{specialized => sp}
import scala.collection.immutable.LazyList

@deprecated(message = "Please use Enumerable", since = "2.10.0")
trait PartialPreviousUpperBounded[@sp A] extends PartialPrevious[A] with PartialNext[A] with UpperBounded[A] {

/**
* Enumerate the members in descending order.
*/
@deprecated(message = "Please use Enumerable.membersDescending.", since = "2.10.0")
def membersDescending: LazyList[A] = {
def loop(a: A): LazyList[A] =
partialPrevious(a) match {
Expand All @@ -41,11 +43,13 @@ trait PartialPreviousUpperBounded[@sp A] extends PartialPrevious[A] with Partial

}

@deprecated(message = "Please use Enumerable", since = "2.10.0")
trait PartialNextLowerBounded[@sp A] extends PartialPrevious[A] with PartialNext[A] with LowerBounded[A] {

/**
* Enumerate the members in ascending order.
*/
@deprecated(message = "Please use Enumerable.membersAscending.", since = "2.10.0")
def membersAscending: LazyList[A] = {
def loop(a: A): LazyList[A] =
partialNext(a) match {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package cats
package kernel

private[kernel] object ScalaVersionSpecificLazyListCompat extends LazyListCompatBase {
override final type T[A] = scala.collection.immutable.LazyList[A]

override final def apply[A](a: A*): T[A] =
scala.collection.immutable.LazyList.apply[A](a: _*)
}
Loading