4 ms·
Yup, this is another example of people not really understanding promises in JS too well. Having to do `Promise.resolve(r + 5)` doesn't really solve that much i
by inglor 11y ago
Yup, this is another example of people not really understanding promises in JS too well.
Having to do `Promise.resolve(r + 5)` doesn't really solve that much in terms of typing, namely the fact you can return a rejected promise or throw an error and so on.
As someone who wrote a promise library or two in typed languages - I don't see it as solving it at all, although what's usually done is that `Promise.resolve` is aliased to `ok` or something similar to simplify the boilerplate.
- tel 11y agoPromises are monads. `ok` is `return :: a -> Promise a` and `then` is `bind :: Promise a -> (a -> Promise b) -> Promise b`. All other behavior arises from that, the monad laws, and the operations throw :: Error -> Promise a reject :: Promise a -- I guess, not sure of the semantics here