Skip to content
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

Swap Thenable for Promise in Async.fromPromise #2237

Merged
merged 2 commits into from
Aug 17, 2021

Conversation

armanbilge
Copy link
Member

Fixes #2236.

vasilmkd
vasilmkd previously approved these changes Aug 16, 2021
Comment on lines 38 to 39
def fromThenable[A](iot: IO[Thenable[A]]): IO[A] =
asyncForIO.fromThenable(iot)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just make fromPromise take a Thenable instead? That would mirror the JavaScript convention of treating "everything that has a then" as being secretly a Promise. It's even fully source and binary compatible in IO, and fully binary compatible in Async.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, makes sense!

It's even fully source and binary compatible in IO, and fully binary compatible in Async.

I feel I am never going to understand binary compatibility 🤔 I didn't think this would be binary compatible because when relaxing the queue signatures to the source/sink supertypes in fs2 in typelevel/fs2#2466, it wasn't binary compatible. Why is it different here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, because type erasure.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The binary type is erased to IO in the former case, and erased to Object in the latter case, so anything goes. :-P

@armanbilge armanbilge changed the title Implement Async.fromThenable ~Implement Async.fromThenable~ Swap Thenable for Promise in Async.fromPromise Aug 16, 2021
@armanbilge armanbilge changed the title ~Implement Async.fromThenable~ Swap Thenable for Promise in Async.fromPromise Swap Thenable for Promise in Async.fromPromise Aug 16, 2021
@armanbilge armanbilge requested a review from djspiewak August 16, 2021 19:21
@djspiewak djspiewak merged commit 4367e27 into typelevel:series/3.x Aug 17, 2021
djspiewak added a commit to djspiewak/cats-effect that referenced this pull request Aug 28, 2021
This reverts commit 4367e27, reversing
changes made to d6817ff.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IO.fromPromise should accept js.Thenable, instead of js.Promise
3 participants