I'm trying to understand the following piece of code (from the Scalaz library):
def kleisliIdApplicative[R]: Applicative[Kleisli[Id, R, ?]] = ...
I'm assuming that a type of the form T[P0, ?]
is a type-constructor that takes a parameter. However I'm no able to find documentation that explains the usage of question marks in type parameters.
A related question is what is the difference between the question mark and an underscore?
Is there a place where all this is well-documented?
The question mark syntax comes from a compiler plugin called kind-projector.
You can see it being included in the scalaz build here: https://github.com/scalaz/scalaz/blob/series/7.3.x/project/build.scala#L310
The plugin translates
Kleisli[Id, R, ?]
into (roughly)
({type L[A] = Kleisli[Id, R, A]})#L
which is a rather convoluted way (but unfortunately the only way in Scala) of expressing a type lambda, i.e. a partially applied type constructor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With