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
trait IsNotFuture[+F] | |
object IsNotFuture{ | |
def apply[F](implicit isf: IsNotFuture[F]) = isf | |
implicit def mkFuture[A] = new IsNotFuture[Future[A]] {} | |
implicit object isf extends IsNotFuture[Any] {} | |
} | |
//No need for a dependent type. All you need is the implicit ambiguity. | |
def inSession[T](fn: (Session) => T)(implicit isNotFuture: IsNotFuture[T]): T = { | |
db withSession fn | |
} | |
// Compiler fails as desired | |
inSession { session => Future(1) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment