News for hackers. Stuff that matters.
Re:What Color Is Your Monad by WorldMaker on Wednesday February 16, 2022 @03:07PM (#30365029)
> 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.

There are no comments on this comment yet.