Open odersky opened 5 years ago
So, just to be clear, in Scala 3.3:
Functor[Either[String, _]]
will be the equivalent of
Functor[[X] => Either[String, X]]
, or what's currently known (with kind-projector) as
Functor[Either[String, ?]]
? Sounds good to me. Especially with the suggested roadmap of incremental changes.
it's too late for native type lambdas to make 2.13, but 2.14 seems like a strong possibility
(for those who haven't seen or thought about this before, https://github.com/lampepfl/dotty/issues/2041 is an earlier iteration of this that explains the motivation more and has some discussion)
Why not do "_
is deprecated for wildcards" in 3.0 and then do the last 2 changes a version earlier?
Why not do "_is deprecated for wildcards" in 3.0 and then do the last 2 changes a version earlier?
We'd like to be able to cross-compile code between 2.14 and 3.0 without warnings (but their might be better ways to achieve this, such as getting 2.14 to understand ?
)
Functor[Either[String, _]]
will be the equivalent ofFunctor[[X] => Either[String, X]]
I would rather expect [X] => Functor[Either[String, X]]
to be precise
@Krever but that wouldn't match how the underscore syntax works for term lambdas (foo(bar(a, _))
is equivalent to foo(x => bar(a, x))
, not x => foo(bar(a, x))
).
My bad, nevermind ;)
Wouldn't it be possible that kind-projector uses another symbol first and deprecates and removes the ? before Scala 3.0 is out?
@nightscape Yes.
Created an issue in kind-projector: https://github.com/non/kind-projector/issues/84
For the record, a cool use case for type-level underscore syntax I mentioned on the forum.
Being able to write:
def foo[A: _ <:< Int] = // ...
instead of:
def foo[A](implicit ev: A <:< Int] = // ...
or instead of the following, which already works but is clumsy:
def foo[A: [T] => T <:< Int] = // ...
I would prefer * for wildcard types. Would that be possible?
We should try to make the next step (deprecation of wildcards now).
Before that I'd like to see Scala 2 support the new syntax by default (right now it's still under -Xsource:3, but using a type named ?
without backticks has been deprecated for a while so I think it's safe to change the default). Also 3.2 is already slated to deprecate non-exhaustive pattern bindings without case
(https://github.com/lampepfl/dotty/pull/14294) and I think we should try not to pile up too many disruptive changes at once, so I'd vote for deprecating only in 3.3
I'd like to see Scala 2 support the new syntax by default
We'd like to eventually use
F[_]
as a short-hand syntax for the type lambda[X] => F[X]
. It would mean we have to switch regular wildcard syntax toF[?]
. The problem is that this is the syntax currently used by KindProjector, because_
was unavailable. The tricky bit is how to shift things around?We need a multi-version strategy for this. I am starting the version count at 3.0, but it could also be something else, 2.14, or even 2.13.
Scala 3.0: Both
_
and?
mean "wildcard". Native type lambdas remove the most pressing need for kind projector. If kind projector is still needed, it would use something else ("__" maybe?)Scala 3.1:
_
is deprecated for wildcardsScala 3.2:
_
is removed for wildcardsScala 3.3:
_
is introduced as a shorthand for type lambdasIf type lambdas get introduced in 2.13, and 2.14, we could also start this process sooner.