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

Issue #4631: Make Later covariant #4632

Merged
merged 2 commits into from
Sep 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions core/src/main/scala/cats/Eval.scala
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ sealed abstract class Eval[+A] extends Serializable { self =>
* This type should be used when an A value is already in hand, or
* when the computation to produce an A value is pure and very fast.
*/
final case class Now[A](value: A) extends Eval.Leaf[A] {
final case class Now[+A](value: A) extends Eval.Leaf[A] {
def memoize: Eval[A] = this
}

Expand All @@ -157,7 +157,7 @@ final case class Now[A](value: A) extends Eval.Leaf[A] {
* by the closure) will not be retained, and will be available for
* garbage collection.
*/
final class Later[A](f: () => A) extends Eval.Leaf[A] {
final class Later[+A](f: () => A) extends Eval.Leaf[A] {
private[this] var thunk: () => A = f

// The idea here is that `f` may have captured very large
Expand Down Expand Up @@ -190,7 +190,7 @@ object Later {
* required. It should be avoided except when laziness is required and
* caching must be avoided. Generally, prefer Later.
*/
final class Always[A](f: () => A) extends Eval.Leaf[A] {
final class Always[+A](f: () => A) extends Eval.Leaf[A] {
def value: A = f()
def memoize: Eval[A] = new Later(f)
}
Expand All @@ -206,7 +206,7 @@ object Eval extends EvalInstances {
* so calling .value does not trigger
* any flatMaps or defers
*/
sealed abstract class Leaf[A] extends Eval[A]
sealed abstract class Leaf[+A] extends Eval[A]

/**
* Construct an eager Eval[A] value (i.e. Now[A]).
Expand Down