Skip to content

Commit

Permalink
Merge pull request #1019 from dialelo/future-pure-eval
Browse files Browse the repository at this point in the history
Use Future#successful in pureEval when possible
  • Loading branch information
adelbertc committed May 6, 2016
2 parents 9a96070 + 0e13ff9 commit 185d0d8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/src/main/scala/cats/std/future.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ trait FutureInstances extends FutureInstances1 {
new FutureCoflatMap with MonadError[Future, Throwable]{
def pure[A](x: A): Future[A] = Future.successful(x)

override def pureEval[A](x: Eval[A]): Future[A] = Future(x.value)
override def pureEval[A](x: Eval[A]): Future[A] = x match {
case Now(x) => Future.successful(x)
case _ => Future(x.value)
}

def flatMap[A, B](fa: Future[A])(f: A => Future[B]): Future[B] = fa.flatMap(f)

Expand Down

0 comments on commit 185d0d8

Please sign in to comment.