Skip to content

Instantly share code, notes, and snippets.

@kubukoz
Last active June 9, 2018 17:22
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 kubukoz/72067ae1b6783493754a38049d6ed5ae to your computer and use it in GitHub Desktop.
Save kubukoz/72067ae1b6783493754a38049d6ed5ae to your computer and use it in GitHub Desktop.
One of the many workarounds for "implicit type parameters" in Scala
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