New syntax: applicative desugaring in for comprehensions (with PR)

I was thinking that a per file import like import scala.language.applicativeFor would be necessary to trigger the desugaring. But that might be hard to do if the desugaring happens too early during compilation.

Indeed this must be enabled explicitly somewhere, just as in Haskell.

Haskell faces the same problem, and it also requires a language extension. But their language flags are available to the whole compiler (parser included). OTOH, they’re whole-file and I suspect sometimes you have to move code to a different file to get the right semantics.

“Purely functional” is not the question. Applicative Do was invented to launch jobs on a cluster, after all—that has plenty of side effects, just independent ones ;-).

Great on-topic link to the Simon Marlow presentation. Thanks for sharing.

1 Like

change the for to par

par {
a <- aa with
b <- bb with
c <- cc
d <- dd
} yield a + b + c + d