Skip to content

Implement kind projector's functionality directly #7139

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

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
Contributor

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

@smarter
Copy link
Member

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
Copy link
Contributor

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 added a commit that referenced this issue Jan 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants