Satyam Agarwal
04/06/2022, 11:58 AMstojan
04/06/2022, 12:13 PMsimon.vergauwen
04/06/2022, 12:17 PMSatyam Agarwal
04/06/2022, 12:26 PMsimon.vergauwen
04/06/2022, 12:46 PMsimon.vergauwen
04/06/2022, 2:01 PMsimon.vergauwen
04/06/2022, 2:01 PMsimon.vergauwen
04/06/2022, 2:01 PMbind from within use and there is no need to nest Either.catch inside Resource#aquiresimon.vergauwen
04/06/2022, 2:06 PMSatyam Agarwal
04/06/2022, 2:49 PMDbLib.useTxn { IllegalStateException().left() }
will not reach ExitCase.Failure -> rollback() and hence, nor, do connection.close()
Therefore, I had to do the nested either, and throw explicitly.
This works as expected:
DbLib.useTxn { throw IllegalStateException() }Satyam Agarwal
04/06/2022, 2:51 PMDbLib.useTxn { throw CancellationException() }
then we will be thrown out of either.simon.vergauwen
04/06/2022, 2:55 PMbind directly in use and that way it works the same as throw IllegalStateException()simon.vergauwen
04/06/2022, 2:56 PMDbLib.useTxn { IllegalStateException().left() } will reach ExitCase.Failure -> rollback() due to the bind inside of useTxn implementationsimon.vergauwen
04/06/2022, 2:57 PMuse { IllegalStateException().left().bind() } will result in ExitCase.Failuresimon.vergauwen
04/06/2022, 2:58 PMDbLib.useTxn { throw CancellationException() } this will result in ExitCase.Cancelled but in that case, it also rolls back, so not sure why that is an issue?simon.vergauwen
04/06/2022, 2:59 PMDbLib.useTxn { Either.catch { throw CancellationException() } } is equal to DbLib.useTxn { throw CancellationException() } so that will also result in ExitCase.Cancelled and a rollbacksimon.vergauwen
04/06/2022, 2:59 PMSatyam Agarwal
04/06/2022, 3:13 PMsimon.vergauwen
04/06/2022, 4:20 PM1.0.3-alpha.37 and arrow.core.continuations.either instead of arrow.core.computations.either then your tests will pass 🙂
Can you let me know if it worked for you? I tried it locally and everything is green for me.simon.vergauwen
04/06/2022, 4:21 PMsimon.vergauwen
04/06/2022, 4:23 PMSatyam Agarwal
04/06/2022, 4:24 PMsimon.vergauwen
04/06/2022, 4:29 PMcomputations is now powered by Effect<E, A>. https://nomisrev.github.io/
And there are more details in the Kdoc, https://github.com/arrow-kt/arrow/blob/main/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/continuations/Effect.kt
Probably easier to read in IntelliJ if you've pulled the alpha version, this will be on the main website after the version is released. The release post will not go very deep on these technical details. If you have any questions be sure to ask them here! 🙂Satyam Agarwal
04/06/2022, 4:36 PMSatyam Agarwal
04/06/2022, 4:58 PMSatyam Agarwal
04/06/2022, 4:59 PMSatyam Agarwal
04/06/2022, 4:59 PMsimon.vergauwen
04/06/2022, 5:02 PMI am guessing either block now leverages effect under the hood ?Yes, the either block implementation is now
effect(f).toEither() 😄simon.vergauwen
04/06/2022, 5:03 PM