4 ms·
I've used Async and LWT in OCaml—libraries for monadic asynchronous programming—and the abstraction can still be useful without syntax sugar. Hell, JavaScript
by tikhonj 11y ago
I've used Async and LWT in OCaml—libraries for monadic asynchronous programming—and the abstraction can still be useful without syntax sugar.
Hell, JavaScript promises are basically a bastardized and slightly inconsistent monad, and they're still useful even without syntax sugar. If we could generalize over the API and use them for other things it would be even better, but that's not the JavaScript way.
- olavk 11y agoHow are JS promises monads?
- tikhonj 11y agoThey actually operate on more or less the same principle as Async and LWT, similar to Haskell's Cont. The .then method is bind. Or it would be if they didn't automatically flatten nested promises. Since they do, then is a hybrid of map and bind that doesn't quite cover the use cases for both.