Skip to content

Instantly share code, notes, and snippets.

@jferris
Created November 16, 2017 21:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jferris/33257aeee907241684b5099875817394 to your computer and use it in GitHub Desktop.
Save jferris/33257aeee907241684b5099875817394 to your computer and use it in GitHub Desktop.
Type Inference
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