Here is a translation of a modification of the example given in [1]:
const promise1 = Promise.resolve(123);
promise1.then(v => v * 2).then((value) => {
console.log(value);
// Expected output: 246
});
into Haskell: ghci> let promise1 :: IO Int = return 123
ghci> promise1 >>= (return . (* 2)) >>= print
246
One key discrepancy worth pointing out is that in the `Promise.then()` API of JavaScript, the function provided to `then` (e.g. `v => v * 2` above) is implicitly composed with a call to `::resolve` in order to turn that function's pure return value, the `Number` 246, into a Promise resolving into the `Number` 246; in Haskell, this operation must be made explicit (hence the composed function `return . (* 2)` passed to the first application of (>>=) or `bind`).You could say that the instance method `Promise.then()` expects an argument of type (a -> b), with the return value of type `b` being implicitly and automatically wrapped into a Monad `m b`, whereas Haskell's bind expects an argument of type (a -> m b) on that operator's right-hand side, with the return value explicitly wrapped into a Monad `m b` by the provided function argument itself.
[0] https://wiki.haskell.org/Monad
[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...