4 ms·
Haskell has the advantage that what you've proposed is an exact conversion of the "flatMap" code, meaning that anything else that you can do with flatMap can be
by jerf 12y ago
Haskell has the advantage that what you've proposed is an exact conversion of the "flatMap" code, meaning that anything else that you can do with flatMap can be used with do notation, which is a lot of things beyond just tying two bits of IO code together.
But in this specific case of just tying two bit of execution together, I'd observe that Erlang is
One(),
Two()
and Go would be
One()
Two()
and that's all regardless of whether One and Two have 0 accesses to IO or do IO dozens of times, and One and Two may also freely call other functions that do arbitrary IO with no further ceremony. The "solution" Erlang and Go offer to callback hell is simply not to have it, and pretty much no matter how you slice it, not having the problem in the first place beats any solution the JS community may or may not settle on.
- tel 12y agoThat's completely fair and accurate. The challenge is handling the genuine concurrency model then, but both Go and Erlang have good tools for doing just that. So it kind of comes down to whether you want to shave off ceremony for concurrency or for all monadic/sequencing operations at once. Honestly, that's a tradeoff.