arrow-kt / arrow

Λrrow - Functional companion to Kotlin's Standard Library
http://arrow-kt.io
Other
6.13k stars 442 forks source link

AutoClose and Resource rehaul/cleanup #3431

Open kyay10 opened 3 months ago

kyay10 commented 3 months ago

This PR simplifies the implementations of AutoCloseScope and ResourceScope and allows some of their functions to be inline. It also makes onRelease not suspending.

github-actions[bot] commented 3 months ago

Kover Report

File Coverage [67.33%]
arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/Bracket.kt 62.71%
arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/Resource.kt 73.81%
Total Project Coverage 57.90%
serras commented 3 months ago

Thanks for your work on making the DSL better, @kyay10. I really like everything which removes constraints from our DSLs, so if we can have suspend and non-suspend functions when before we had only the former, that's a huge win for me!

Having said so, we promised to keep source compatibility between 1.2.x and 2.0 (except for the changes in Optics KSP), and some of these changes break that source compatibility. I would really like to keep this promise: we've already broken code in the past, and I really want to make things right this time. This means that, at the very least, the same functions need to be exposed from the same package or class they originally were.

Going also in the direction pointed by @nomisRev, maybe this could be easier to review if the fundamental changes were broken from the refactoring changes. In general in Arrow we try to not refactor things like val to let style, or vice versa, and just keep the original author's code.