cujojs/most — pull request #12 by briancavalier (2014-02-06 12:45:51+00:00)
Title: Add promise

Mostly for discussion. This is a lazy monadic promise with map, flatMap, and ap. It also has a then() that recursively unwraps promises and thenables, so is *almost* Promises/A+ interoperable (see below).

It's lazy in that the promise doesn't run its resolve until done() is called the first time. So, promises must be consumed via `done`, before any work is done. That also forces people to handle errors since `done` will throw loudly on any unhandled rejection (thus crashing node).

The fact that `then` is lazy causes Promises/A+ and ES6 interop issues. If assimilation relied on `done` instead of `then`, it would all work out. Similarly, if there is a clean way to make this Promise impl's `then` eager, it would probably also work out, but that seems less desirable.

Another option might be to say this thing is not a Promise, and remove `then`.