Description
The page for multiple parameter lists shows one use case of multiple parameter lists being to drive type inference, and it shows an example that it claims does not compile in Scala 2 or 3:
val numbers = List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
def foldLeft1[A, B](as: List[A], b0: B, op: (B, A) => B) = ???
// docs.scala-lang says this should not compile, but it works fine.
def notPossible = foldLeft1(numbers, 0, _ + _)
I gather there have been a number of improvements to Scala's type inference, such that in both Scala 3 LTS (3.3.5) and Scala 3 Next (3.6.3), the above code compiles and infers the type of notPossible
perfectly fine.
Unfortunately, I'm not familiar enough with Dotty's type inference to know whether or not driving type inference is still an important use case for multiple parameter lists; I suggest that we either/both:
- Come up with a new example that fails in current Scala 3, and/or
- Emphasize the following use cases, which I think are more common in modern Scala 3 code:
- Partial function application (which is already discussed in the doc),
- The ability to create syntax similar to control structures, including braceless lambdas (which is not discussed in the doc).
I would be happy to update the page and make a PR, but I wasn't sure if somebody more familiar with the current type inference algorithm could come up with a replacement example.