purescript-contrib/purescript-angular — pull request #20 by dylex (2014-10-29 03:14:26+00:00)
Title: Option to eliminate pureResolve from Bifunctor Promise

For discussion, may be better approaches.

Picking up on a discussion on #16, `pureResolve` and `pureReject` unfortunately create new angular modules just to create a promise. I believe this may especially be an issue in angular 1.3, where the promise framework has been changed to keep more state, so promises from different modules won't play well together (just based on a simple code review, `pending` is shared state in `processQueue`).

This is one way to eliminate them from Bifunctor and a couple other places. I'm not sure how to fix Applicative.pure, yet. This approach works because angular looks at the return values from resolve/reject functions and, if they are not promises, treats them as the new result value (which is also far more efficient than constructing another promise). However, there is a problem here in that if the user actually returns a Promise in a `thenPure` argument, the types will no longer be correct, because angular will have flattened the extra Promise without us knowing (and we can't write the type "anything but Promise"). (The converse is already an issue: it's actually impossible in angular to create promises that resolve to a promise, but the types here don't know that.)