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

Fix Capture instances for IO and Future #195

Merged
merged 2 commits into from Feb 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -82,7 +82,7 @@ class CatsEffectJSSpec extends AsyncFunSuite with Matchers {
}

// only here for the 80% coverage, to remove once JS makes use of Captures
test("IOCapture == IO.pure") {
ioCaptureInstance.capture("a") shouldBe IO.pure("a")
test("IOCapture == IO.apply") {
ioCaptureInstance.capture("a") shouldBe IO("a")
}
}
Expand Up @@ -21,6 +21,6 @@ import github4s.free.interpreters.Capture

trait IOCaptureInstance {
implicit val ioCaptureInstance = new Capture[IO] {
override def capture[A](a: ⇒ A): IO[A] = IO.pure(a)
override def capture[A](a: ⇒ A): IO[A] = IO(a)
}
}
6 changes: 3 additions & 3 deletions github4s/shared/src/main/scala/github4s/Implicits.scala
Expand Up @@ -19,7 +19,7 @@ package github4s
import cats.instances.FutureInstances
import cats.{Eval, FlatMap, Id, Monad, MonadError}
import github4s.free.interpreters._
import scala.concurrent.Future
import scala.concurrent.{Future, ExecutionContext}

object implicits
extends FutureCaptureInstance
Expand All @@ -29,8 +29,8 @@ object implicits

trait FutureCaptureInstance {
//Future Capture evidence:
implicit val futureCaptureInstance = new Capture[Future] {
override def capture[A](a: ⇒ A): Future[A] = Future.successful(a)
implicit def futureCaptureInstance(implicit ec: ExecutionContext) = new Capture[Future] {
override def capture[A](a: ⇒ A): Future[A] = Future(a)
}
}

Expand Down