I have read a blog about existential type in Scala:Existential types in Scala
In this blog, it mentions an example:
Map[Class[T forSome { type T}], String]
Map[Class[T] forSome { type T}, String]
Map[Class[T], String] forSome { type T}
His explanation. "the third one is the supertype of all map types such that there is some T such that they are a Map[Class[T], String]. So again, we've got some fixed class type for keys in the map - it's just that this time we don't know what type it is. The middle one however has keys of type Class[T] forSome { type T }. That is, its keys are classes which are allowed to have any value they want for their type parameter. So this is what we actually wanted."
The explanation is not easy to follow. What are the differences between the second and third one in the code example? Could anyone give us some examples?
The blog also mention that Map[Class[_], String]
is equivalent to the third one in the example, when we actually want the second one. Will this affect the semantics when we use _
for existential type?