Skip to content
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

Implement kind projector's functionality directly #7139

Closed
biboudis opened this issue Aug 30, 2019 · 2 comments
Closed

Implement kind projector's functionality directly #7139

biboudis opened this issue Aug 30, 2019 · 2 comments

Comments

@biboudis
Copy link
Member

@biboudis biboudis commented Aug 30, 2019

We already accept both _ and ? as a wildcard. Following kind projector, we should now accept * as a parameter placeholder for a type lambda.

@biboudis biboudis created this issue from a note in Scala 3.0 Planning (To do) Aug 30, 2019
@smarter

This comment has been minimized.

Copy link
Member

@smarter smarter commented Sep 1, 2019

Note that this should be guarded by the (already existing) -Ykind-projector, which I think should also support the other syntaxes for type lambdas implemented by kind-projector to ease cross-compilation:

Lambda[A => (A, A)]
λ[A => (A, A)]
λ[(+[A], +[B]) => Either[A, B]]
λ[(`+A`, `+B`) => Either[A, B]]

See https://github.com/typelevel/kind-projector

@travisbrown

This comment has been minimized.

Copy link
Contributor

@travisbrown travisbrown commented Dec 13, 2019

For what it's worth we could very easily live without kind-projector's variance syntax in Cats (see this PR for the change), and in all of the other Typelevel or Typelevel-adjacent projects I just checked.

I currently have a -Ykind-projector implementation for * and am working on λ[A => ...], and am hoping to have a PR ready early next week, but I personally don't see supporting kind-projector's -* or the backticked variance stuff as a priority.

travisbrown added a commit to travisbrown/dotty that referenced this issue Dec 16, 2019
  - Support * placeholder (including in tuple and function types)
  - Support λ alternative to =>> syntax
  - Add tests
travisbrown added a commit to travisbrown/dotty that referenced this issue Jan 23, 2020
This change adds support for a subset of kind-projector's syntax behind
the existing -Ykind-projector flag.

It supports the following kind-projector features:

- * placeholder (Functor[F[L, *]] instead of Functor[[x] => F[L, x]]).
- * in tuple types (Functor[(A, *)] instead of Functor[[x] => (A, x)]).
- * in function types (both Functor[S => *] and Functor[* => T] work).
- λ syntax (λ[x => Functor[(x, x)]] for Functor[[x] => (x, x)]).

There are a few things kind-projector provides that the flag doesn't:

- ? as a placeholder (since it collides with wildcards).
- * as a placeholder in infix types.
- Lambda as an alternative for λ.
- λ arguments of a kind other than * (no λ[f[_] => Functor[f]]).
- Variance annotations on either * or λ arguments.
- Polymorphic lambda values (λ[Vector ~> List](_.toList)).

The changes have no effect on parsing if -Ykind-projector isn't enabled.
@odersky odersky closed this in b5adfcb Jan 23, 2020
odersky added a commit that referenced this issue Jan 23, 2020
Fix #7139: Implement kind-projector compatibility
Scala 3.0 Planning automation moved this from To do to Done Jan 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.