typelevel / typelevel/kind-projector

Alternative syntax for polymorphic lambdas (for Shapeless)

Open
#138 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
923
Forks
75
Avg merge
6h 5m
Merged PRs (30d)
1

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by examining the existing λ[Id => Option].run syntax and the requested object g extension syntax. Use the Shapeless Case1.Aux[g.type, Id[Int], Option[Int]] example as the acceptance case, and determine whether alternate method names such as run must also be supported. Done means the singleton g.type form compiles in the stated use case.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.