Skip to content

multiple type parameter lists #4719

Closed as not planned
Closed as not planned
@scabug

Description

@scabug

(quoting Miles Sabin)

We can encode multiple type parameter blocks on
methods in current Scala, albeit inefficiently and clumsily,

 def foo[A1, A2][B1, B2](p1 : (A1, B1)) : (A2, B2) = ...

can be encoded as,

 def foo[A1, A2] = new { def apply[X1, X2, B1, B2](p1 : (A1,
B1))(implicit ev : X1 =:= A1) : (A2, B2) = ... }

(/quoting Miles Sabin)

Multiple type parameter lists would internally be represented by nested PolyTypes, which is possible due to the NullaryMethodType refactoring. I see two options for type inference:

  • reduce to single type parameter list by bunching all type parameters together
  • solve type parameters in batches, so that the concrete type chosen for later type parameters does not influence the inference of earlier type parameters (in lists on the left), au contraire, later type param's inference depends on the types chosen for type params in lists on their left (see also fundeps in haskell)

see also: named and default type parameters

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementfixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions