Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

Revert IO<E, A> back to IO<A> #208

Merged
merged 12 commits into from
Jul 3, 2020
Merged

Revert IO<E, A> back to IO<A> #208

merged 12 commits into from
Jul 3, 2020

Conversation

aballano
Copy link
Member

@aballano aballano commented Jul 1, 2020

This reverts commit 0d7c9c2.

Fixes #175

◀️ Depends on arrow-kt/arrow-ank#37
▶️ Unlocks arrow-kt/arrow-ank#41
▶️ Unlocks arrow-kt/arrow-incubator#118
▶️ Unlocks arrow-kt/arrow-check#14
▶️ Unlocks arrow-kt/arrow-integrations#33
▶️ Unlocks arrow-kt/arrow-examples#5
▶️ Unlocks arrow-kt/arrow-optics#58
▶️ Unlocks arrow-kt/arrow-core#173

@aballano aballano marked this pull request as ready for review July 1, 2020 13:35
@@ -1065,7 +1187,7 @@ fun <E, A, B, E2 : E> IOOf<E, A>.flatMap(f: (A) -> IOOf<E2, B>): IO<E2, B> =
* }
* ```
*/
fun <E, A> IO<E, EitherOf<E, A>>.flattenEither(): IO<E, A> =
fun <E : Throwable, A> IO<EitherOf<E, A>>.flattenEither(): IO<A> =
Copy link
Member Author

Choose a reason for hiding this comment

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

👀 @nomisRev @JorgeCastilloPrz Although not as useful as before, I left this functions here but restraining E to throwable, so they can still be used in certain situations

Copy link
Member

@nomisRev nomisRev left a comment

Choose a reason for hiding this comment

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

Nice work! 👏 👏 👏
There is some regression in this PR we should solve before merging.

val disposable = fix().unsafeRunAsyncCancellable { either ->
either.fold(cont::resumeWithException) { cont.resume(it) }
val disposable = fix().unsafeRunAsyncCancellable { result ->
result.fold<Unit>(cont::resumeWithException, cont::resume)
Copy link
Member

Choose a reason for hiding this comment

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

If you specify Unit for fold does it allow you to use cont::resume and otherwise it doesn't? :O

Copy link
Member Author

Choose a reason for hiding this comment

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

No idea, just removed the explicit type to see if it compiles

Copy link
Member Author

Choose a reason for hiding this comment

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

And it doesn't, need to add it explicitely 😂

Copy link
Member

Choose a reason for hiding this comment

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

Cool. Didn't know you could fix bypassing <Unit> to fold.
I've always made anonymous lamdas

arrow-fx-rx2/src/test/kotlin/arrow/fx/SingleKTests.kt Outdated Show resolved Hide resolved
arrow-fx/src/main/kotlin/arrow/fx/IOConnection.kt Outdated Show resolved Hide resolved
arrow-fx/src/main/kotlin/arrow/fx/IOFrame.kt Outdated Show resolved Hide resolved
arrow-fx/src/main/kotlin/arrow/fx/KindConnection.kt Outdated Show resolved Hide resolved
arrow-fx/src/test/kotlin/arrow/fx/SemaphoreTest.kt Outdated Show resolved Hide resolved
IO.Bind(IO.ContextSwitch(applyRelease(ExitCase2.Exception(e)), IO.ContextSwitch.makeUncancellable, disableUncancellableAndPop),
ReleaseRecoverException(e))
override fun recover(e: Throwable): IO<B> =
IO.Bind(
Copy link
Member Author

Choose a reason for hiding this comment

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

@nomisRev I brought back this as well FYI

Copy link
Member

Choose a reason for hiding this comment

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

👌

Copy link
Member

@nomisRev nomisRev left a comment

Choose a reason for hiding this comment

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

Awesome work!! Looks great! 👏 👏 👏

It's not in the diff, but one more class can be removed. 🎉
class UnhandledError(val error: Any?) : Throwable(message = "Encountered UnhandledError during cancellation: $error") {

@aballano aballano merged commit 32d3d45 into master Jul 3, 2020
@aballano aballano deleted the ab/revert-bio branch July 3, 2020 10:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

["Request"] Revert IO<E, A> back to IO<A>
2 participants