Last active
June 9, 2018 17:22
-
-
Save kubukoz/72067ae1b6783493754a38049d6ed5ae to your computer and use it in GitHub Desktop.
One of the many workarounds for "implicit type parameters" in Scala
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
class HasKF[F[_]] private { | |
type KF[A, B] = Kleisli[F, A, B] | |
} | |
object HasKF { | |
private val s: HasKF[Id] = new HasKF[Id] | |
def apply[F[_]]: HasKF[F] = s.asInstanceOf[HasKF[F]] | |
} | |
class AService[F[_] : Applicative] { | |
val x: HasKF[F]#KF[String, Int] = Kleisli.pure(10) | |
} | |
object AService { | |
def main(args: Array[String]): Unit = { | |
println(new AService[Id].x("hello")) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment