Apply Within – Bringing applicative desugaring to Scala for-notation

Scala dev hacks for-loops to batch work, sparks nerd war

TLDR: A Scala dev built a macro to make simple loops batch work like Haskell’s tool Haxl, potentially speeding up data fetching. The community split fast: enthusiasts love the performance promise, while purists warn it’s overcomplicated and hard to maintain, with memes and arrow jokes flying.

A brave Scala tinkerer just dropped a wild experiment: a macro that teaches Scala’s friendly “for” loop to secretly batch work like Haskell’s famous Haxl. Translation: fewer slow, one-by-one calls and more “do it all at once” magic. The blog — Apply Within — reads like a love letter to concurrency and a rant about arrows and algebra, but the comments are the real show.

Fans cheered, calling it “free speed without the headache,” and begged for demos showing faster data fetching. Haskell veterans rolled in with popcorn: “We’ve had this for years,” they smirked, waving Haxl like a victory flag. Scala purists fired back: “Macros are chaos. Don’t duct-tape the language!” Meanwhile, the practical crowd asked, “Why not just use libraries like Fetch?” Cue category theory jokes, left-arrow memes, and someone posting a picture of a “BFF Monad” friendship bracelet.

The biggest debate: is this clever hack a smart shortcut or a maintenance nightmare? The author’s own rueful tone only fueled the drama. One camp sees a cool way to batch network calls inside familiar code. The other sees a rabbit hole of magical syntax that future teammates will curse. Tech Twitter-approved chaos ensues.

Key Points

  • The article proposes bringing applicative desugaring to Scala’s for-notation to improve concurrent data retrieval.
  • It compares Haskell’s Haxl and Scala’s Fetch, noting Haxl benefits from compiler-supported do-notation extensions.
  • Haxl batches dependent queries by building a dependency tree and executing independent requests together.
  • Standard monadic ordering via fmap and >>= is insufficient for batching; compiler changes enable applicative behavior in do-notation.
  • The author plans a Scala macro to extend for-notation similarly, aiming to demonstrate its success and discuss lessons learned.

Hottest takes

"Stop turning Scala into cosplay Haskell" — bytebard
"Macros are foot-guns, but this one's a bazooka" — cyclebreaker
"If this batches my API calls, tattoo a functor on me" — cat_theorist
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.