Swap Thenable for Promise in Async.fromPromise#2237
Swap Thenable for Promise in Async.fromPromise#2237djspiewak merged 2 commits intotypelevel:series/3.xfrom
Thenable for Promise in Async.fromPromise#2237Conversation
| def fromThenable[A](iot: IO[Thenable[A]]): IO[A] = | ||
| asyncForIO.fromThenable(iot) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Ahh, because type erasure.
There was a problem hiding this comment.
The binary type is erased to IO in the former case, and erased to Object in the latter case, so anything goes. :-P
Async.fromThenableAsync.fromThenable~ Swap Thenable for Promise in Async.fromPromise
Async.fromThenable~ Swap Thenable for Promise in Async.fromPromiseThenable for Promise in Async.fromPromise
Fixes #2236.