5 ms·
Promises are functors not monads because they map (.then) but the return value becomes the new promise. The chain is flat Rxjs streams are monads because you c
by joshribakoff 8y ago
Promises are functors not monads because they map (.then) but the return value becomes the new promise. The chain is flat
Rxjs streams are monads because you can map a stream to a stream which wraps the inner stream in a source stream, which you can then flatMap.
- matt_kantor 8y ago> Promises are functors not monads That's not quite true. `then` is a weird hybrid of `map` and `bind`. If its callback returns a Promise it acts like `bind` (you don't get a nested Promise), but otherwise it acts like `map`. And to be pedantic, Promise is neither a functor nor monad because `then` doesn't follow the necessary laws.