-
Notifications
You must be signed in to change notification settings - Fork 13
Make use of purescript-web-promise
#30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
How does this relate to #29 ? That PR is just awaiting some decisions on breaking changes |
Hah 🤦♂️ I'd argue that the implementation here is less surprising/more correct due to the use of In the other PR, if the I also chose to expose I agree with moving away from the |
Paging @YourFin |
Sorry for the delay, my github notifications are crap ($megacorp employer uses something else). Feel free to pester me on discord if I'm not being responsive here; you should be more likely to get a response. As far as general comments go, I think it might be worth merging our PRs to some extent so you can pick up the extra dependency upgrades in mine (i.e. the spago stuff + updated package.json). That can be done separately though, and otherwise I prefer your PR.
🥳 I was looking for this in web-promise when writing my PR, but I had already shaved enough yaks on my way here. Glad to see it!
I'm elated to see someone with more expertise taking a look at this. Can we please add a test case to make sure nobody like me comes through and breaks this behavior in the future?
No strong preference on my part here. Including "Web.Promise" in the module name might soothe compatibility fears as a weary user, but that feels like quibbling for my ego's sake more than anything. |
src/Control/Promise.purs
Outdated
|
||
-- | Convert an Aff into a Promise. | ||
fromAff :: forall a. Aff a -> Effect (Promise a) | ||
fromAff aff = promise (\succ err -> runAff_ (either err succ) aff) | ||
fromAff :: forall a. Promise.Flatten a a ⇒ Aff a -> Effect (Promise a) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not forall a b. Promise.Flatten a b ⇒ Aff a -> Effect (Promise b)
?
@i-am-the-slime and I were discussing this topic because we are working on an isomorphic fetch library and just stumbled upon the issue that |
I agree with @sigma-andex's proposal - added my 2p on the linked issue there. @YourFin - my turn to apologise for the delay! All good points, will merge/base off your commit to get the dependencies, etc. / add a couple of tests / relax the |
One other minor thing @garyb - after the included commit it looks like there will be a mix of fancy unicode arrows and the banal ascii ones in the code - could you be sure to update the final version for consistency? |
Yes, absolutely. I need to set something up that tells me off for using fancy arrows outside of my/work projects 😄 - I'll add |
Finally updated this again!
I did try adding a test to check the |
I'll take a full look at the code later, appreciate if @YourFin could do the same (I think your concern was addressed?). I'm minded to get this PR merged then look to get this repo moved into contrib, as has been repeatedly suggested (whether that should be a transfer or copy I don't know - but can consider the rename also). |
Okay, sounds good! I can create a new repo there with the revised name if we want to do it that way. |
A bit late to the party here, but LGTM! |
@garyb lets do that, recreating in contrib appears to be the best idea if renaming. Were we thinking promise-aff per the namespace? |
Yeah, I think so. Will sort it out (create, push history, initial release) later today 👍 |
|
I have no problem with either, probably |
Ok, we have the new repo https://github.com/purescript-contrib/purescript-js-promise-aff and I've pushed the history of this one into that now. Going to do a few changes so it's configured like the rest of the contrib libraries, then will make a release and get it published. |
It'd be nice if we could switch over to using this so that we have a consistent type for
Promise
s.web-promise
isn't one of the heavier web libraries either, adding it to this didn't bring anything else in new transitively.This is a breaking change, even aside from switching the type of
Promise
, as now we deal with aPromise.Rejection
rather thanForeign
in the error coercion function.