Created
November 16, 2017 21:24
-
-
Save jferris/33257aeee907241684b5099875817394 to your computer and use it in GitHub Desktop.
Type Inference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cats.data.EitherT | |
import cats.instances.future._ | |
import cats.syntax.all._ | |
import scala.concurrent.{ExecutionContext, Future} | |
/* | |
* Compiled with: | |
* Scala 2.12.4 | |
* cats-core 1.0.0-RC1 | |
* -Ypartial-unification | |
*/ | |
object Demo { | |
implicit val ec: ExecutionContext = ExecutionContext.global | |
type Result[A] = EitherT[Future, String, A] | |
val works: Result[Int] = 5.pure[Result] | |
val fails: Result[Int] = 5.pure | |
// [error] Demo.scala:13: type mismatch; | |
// [error] found : scala.concurrent.Future[Int] | |
// [error] required: Demo.Result[Int] | |
// [error] (which expands to) cats.data.EitherT[scala.concurrent.Future,String,Int] | |
// [error] val fails: Result[Int] = 5.pure | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment