4 ms·
> Javascript programmers seem to have no problem using a monad every day (promises) Using (something similar to) a monad (Javascript promises do not form a mon
by dragonwriter 7y ago
> Javascript programmers seem to have no problem using a monad every day (promises)
Using (something similar to) a monad (Javascript promises do not form a monad) successfully is different than using the monad abstraction successfully.
> and they are huge fans of do-notation in the from of async/await.
Async / await is not monadic do-notation. Arguably, it has a somewhat similar relationship to the underlying promise abstraction that do-notation had to the monad abstraction, but they aren't the same thing.
> Imperative programmers do not seem to have an issue with the idea of assignment, why are monads problematic
Why are the two halves of this sentence connected to each other since they have no relationship other than the proximity they've been (bizarrely) placed in.
- jsjolen 7y agoYeah, you're right that in some manners JS's promises do extend the semantics of a monad (notably in its impl. of return) but it is a monad though: function bindPromise(p, f) { return p.then(f); } function returnPromise(a) { return new Promise.resolve(a); } Proof of the laws left as an exercise to the reader :). But yes, you are correct that promises do quite a bit more than only being a monad, for example because of how they treat errors. EDIT: I concede, I am wrong! https://buzzdecafe.github.io/2018/04/10/no-promises-are-not-monads https://buzzdecafe.github.io/2018/04/10/no-promises-are-not-...