As long as the lambda-containing thing is last, all you need is to double-down on infix syntax rather than abandon it:
xs map s =>
val n = s.length
if n < 5 then s * n
else s.toUpperCase
and
xs foldLeft(0) (acc, x) =>
acc + x
The problem comes when you have multiple parameter blocks or a lambda that is part of a parameter block, because you’re mixing styles: delimited parens, but non-delimited blocks. That’s already true even with stuff like multi-line if/else
def foo(p: Int => Boolean, q: Int => Boolean) = ???
foo(
i =>
if (i < 189571) bippy(i/2)
else whatchamacallit(i, i + 1) < 893475,
j =>
if (lovely(j)) checkIfFlower(j)
else false
)
This is about the best one can do and there’s still an awkwardness in finding that comma that separates the two.
Anyway, I just don’t buy that multi-line lambdas are hard at all. =>
can just be an end-of-line block opener. The problem is that the other syntax doesn’t support them. (You end up surrounding things with parens instead of braces, and the parens were already optional with braces, so you accomplish precisely nothing.)
P.S. Want chaining? No worries, just triple-down on infix syntax:
xs
map s =>
val x = foo(s)
bar(x, s, quux(x))
filter y =>
val z = baz(y)
isScrupulated(z, bippy(y, z))
Maybe we don’t want to write things that way because braces or parens make things more clear, but hey, that’s why braces are optional. Sometimes they make things more clear.