Negative information in type inference not used #17824
Replies: 0 comments 2 replies
-
Moving to the feature request repo, is there a practical usage for this? |
Beta Was this translation helpful? Give feedback.
-
That makes sense. The code that triggered this question was: ...
case App(e1, e2) => EM(m_var, m_app.updatedWith(e1)((_.updatedWith(e2)(f)).liftXT)) which doesn't compile because of the above limitation. ...
case App(e1, e2) => EM(m_var, m_app.updatedWith(e1)(((m2: ExprMap[V1]) => m2.updatedWith(e2)(f)).liftXT)) which reveals a lot less of the structure due to the expanded function and type signature. Scala 3 has much better syntax for enum's and extension methods and improves typeclasses. For the following examples, this is very rare: extension [A, B, T](pf: PartialFunction[(A, B), T])
inline def swap: PartialFunction[(B, A), T] = (b, a) => pf(a, b)
inline def bidirectional = pf orElse pf.swap Because you're not likely to map over a container of binary partial functions. extension [A](as: Iterable[A])
def forallPairs(p: (A, A) => Boolean) =
as.forall(x => as.forall(y => p(x, y))) Because reducing a nested iterable to an iterable of booleans with a known collections is about as likely as it is with a known binary function. |
Beta Was this translation helpful? Give feedback.
-
Compiler version
3.0.2
Minimized code
Output
Expectation
Work like
so being automatically expanded to
I realize something this basic is likely a choice or something that behaves poorly in complex examples.
Nevertheless, this happens a lot, so I think it's worth discussing.
Beta Was this translation helpful? Give feedback.
All reactions