-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
pre-SIP: Underscore Syntax for Type Lambdas #5379
Comments
So, just to be clear, in Scala 3.3:
|
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, #2041 is an earlier iteration of this that explains the motivation more and has some discussion) |
Why not do " |
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 |
I would rather expect |
@Krever but that wouldn't match how the underscore syntax works for term lambdas ( |
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: |
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] = // ... |
Motivation: There is a proposal for F[?] to denote a wildcard (currently F[_]) in Scala 3.0+ and F[_] to be a shorthand syntax for type lambda (F[?] with current kind-projector syntax) in Scala 3.3+ (see scala/scala3#5379). Supporting an additional placeholder will allow users to gradually move from `?` to `*` before Scala 3.0 is out.
Motivation: There is a proposal for F[?] to denote a wildcard (currently F[_]) in Scala 3.0+ and F[_] to be a shorthand syntax for type lambda (F[?] with current kind-projector syntax) in Scala 3.3+ (see scala/scala3#5379). Supporting an additional placeholder will allow users to gradually move from `?` to `*` before Scala 3.0 is out. Resolves typelevel#84.
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 |
Like scala#9721, the goal here is to ease cross-compilation between Scala 2 and 3 code as we prepare for `_` as wildcard to be deprecated in Scala 3 (cf scala/scala3#5379). This is technically a source-breaking change, but using a type named ? without backticks is deprecated since 2.13.6 (scala#9626) and defining a type named ? without backticks is disallowed since 2.13.7 (scala#9735). The only known user of ? as a type name was the kind-projector plugin, but support for this syntax was removed from the plugin a year ago (typelevel/kind-projector#186), so I believe this change won't be disruptive.
PR: scala/scala#9990 |
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.
The text was updated successfully, but these errors were encountered: