3 ms·
> Javascript, of course, has async/await syntax. I’m curious if that is equivalent to for expressions/do notation and could (in theory) be used for monads other
by WorldMaker 5y ago
> Javascript, of course, has async/await syntax. I’m curious if that is equivalent to for expressions/do notation and could (in theory) be used for monads other than Promise
It's very similar indeed to do-notation.
The contract for JS async/await is really simple, too, it basically supports any "Thenable" object: an object with a monadic bind function called .then(). It's basically "duck typed" in JS, if it has a .then() function that takes the right sort of callback you can await it.
I haven't seen any practical uses of async/await syntax for monads other than Promise, but it's very doable in theory.