-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Existential higher kinded type does not work #9445
Comments
Imported From: https://issues.scala-lang.org/browse/SI-9445?orig=1 |
I don't think it's a regression of #9008 This issue is causing problems with implicit resolution for HKTs: trait Functor[F[_]]
implicit val optFunctor: Functor[Option] = ???
implicit def genFunctor[F[_]]: Functor[F] = ???
implicitly[Functor[Option]] // ambiguous Somehow the bounds of existential HKTs seem wrong to me: val universe = scala.reflect.runtime.universe.asInstanceOf[JavaUniverse]
import universe._
def bounds(sym: Symbol) = (sym.info.bounds.lo, sym.info.bounds.hi)
trait T { type F[_] }
println(bounds(symbolOf[F[Int] forSome { type F[_] }])) // ([_]Any,[_]Any)
println(bounds(symbolOf[T#F[Int]])) // ([_]Nothing,[_]Any)
println(bounds(symbolOf[A forSome { type A }])) // (Nothing,Any) Setting the lower bound explicitly doesn't help: println(bounds(symbolOf[F[Int] forSome { type F[_] >: Nothing }])) // ([_]Any,[_]Any) Where are those created? |
The problem is here. The |
Fixing this reveals a deeper limitation though: // This works:
scala> implicitly[H[T] <:< (H[F] forSome { type F[_, _] })]
res0: H[T] <:< H[_[_, _]] = <function1>
// But we can't create a value of that type:
scala> def hf: H[F] forSome { type F[_, _] } = ???
<console>:5: error: can't existentially abstract over parameterized type F
lazy val $result = hf |
@joroKr21 I suspect that the restriction on existentially abstracting over parameterized types is obsolete ... my hunch is that it was introduced to mask some of the issues with higher kinded types that are touched on in this and related tickets. I think that we should drop the restriction and fix the underlying issues that would reveal. |
Yes, that restriction manifested itself only in the REPL. It's not a problem in compiled code. |
The text was updated successfully, but these errors were encountered: