You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
valnumbers=List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
deffoldLeft1[A, B](as: List[A], b0: B, op: (B, A) =>B) =???// docs.scala-lang says this should not compile, but it works fine.defnotPossible= 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.
The text was updated successfully, but these errors were encountered:
amordahl
changed the title
Multiple Parameter Lists Doc is no longer accurate.
Multiple Parameter Lists Doc is no longer accurate w.r.t. type inference
Feb 19, 2025
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:
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:
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.
The text was updated successfully, but these errors were encountered: