|
|
|
|
|
by inglor
3636 days ago
|
|
This comment is correct - promises in JavaScript started like this and settled on their current API for ergonomics. Here is a standard promise implementation with deferred execution that never took off: https://github.com/then/lazy-promise A lot of tough calls had to be made and pragmatic best interest of users typically triumphed over purity. A promise is monadic if you drop exceptions and use the `then` overload which is `bind`. You have a `pure` - `resolve`. The promise constructor has to exist to interop with callbacks but for no other reason really. |
|
It became a pain point for me when using Promises as part of a larger abstraction, where the exact use was not known. Then I've worked around the strictness by embedding a "trigger" into a set of Promises so that I can set them off all at once, after they are all created.
Good article, btw. One of these days the Monad/Category lightbulb is going to go off for me, and this brought me closer to that using a familiar example.