Skip to content

Alternative syntax for polymorphic lambdas (for Shapeless) #138

Description

@yangzai

Currently kind-projector allows

val g = λ[Id ~> Option].run(x => Some(x))

to be rewritten as

val g = new (Id ~> Option) {
  def run[A](x: Id[A]): Option[A] = Some(x)
}

I was wondering if there could be an alternative syntax that rewrites to

object g extends (Id ~> Option) {
  def apply[A](x: Id[A]): Option[A] = Some(x)
  
// if possible it should allow rewrite to other method names as well:
//  def run[A](x: Id[A]): Option[A] = Some(x)
}

in situations where the singleton type g.type is required.

i.e. in Shapeless

the[Case1.Aux[g.type, Id[Int], Option[Int]]]

should compile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions