Skip to content

Commit

Permalink
Merge pull request #4632 from yanns/4631_covariant_later
Browse files Browse the repository at this point in the history
Issue #4631: Make Later covariant
  • Loading branch information
satorg authored Sep 4, 2024
2 parents 93b0148 + 94526a9 commit 927a9bb
Showing 1 changed file with 4 additions and 4 deletions.
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

0 comments on commit 927a9bb

Please sign in to comment.