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
@soc said:
I'd tentatively say that this behavior works as intended. The idea is that the type inference looks at one parameter list as a whole, but considers each of them one after the other.
@retronym said:
Yes, this behaviour or inference runs pretty deeply through the way that applications are type checked, and it is relied upon in APIs like foldLeft, which allow the constraints accumulated by considering the first argument list to allow you to omit types in the second argument list.
deffoo[A, B](a: A)(f: A=>B)
foo(1)(x =>-x) // no need to write `x: Int => -x` here
does not compile:
If a single parameter list is used, A is inferred as Either[Int, Int], as hoped.
A real-world example of this is Option.fold, which requires an explicit type in circumstances where pattern-matching, or map/getOrElse would not.
The text was updated successfully, but these errors were encountered: