phldavies
04/29/2022, 1:19 PMResource.parZip
when `parZip`ing a `parZip`’d resource 🙂
suspend fun main() = int(1)
.parZip(int(2), Int::plus)
.parZip(int(3), Int::times)
.use { println("using $it") }
private fun int(n: Int) = resource {
n.also { println("acquiring $it") }
} release {
println("releasing $it")
}
outputs
acquiring 2
acquiring 1
acquiring 3
using 9
releasing 3
and never releases 1 and 2simon.vergauwen
04/29/2022, 1:21 PMResource#parZip
was rewritten to be build on top of the resource { }
DSL in 1.1.0.
Can you give that a shot there?phldavies
04/29/2022, 1:38 PM1.1.2
results in this:
acquiring 2
acquiring 1
acquiring 3
using 9
releasing 1
releasing 3
releasing 2
simon.vergauwen
04/29/2022, 1:39 PMphldavies
04/29/2022, 1:41 PMIterable<A>.parTraverseResource
method but can get away with traverseResource
for now to unblock my task and look into an upgrade to 1.1.x next 😉simon.vergauwen
04/29/2022, 1:41 PMsimon.vergauwen
04/29/2022, 1:42 PMresource {
listOf(..).parTraverse {
resource(it).bind()
}
}
For doing parTraverseResource
phldavies
04/29/2022, 1:43 PMresource { }
DSL, sure - that’ll be my go-to replacement once I’ve made the jump. 🙏simon.vergauwen
04/29/2022, 1:43 PMResource#parZip
it's also simply resource
DSL + the regular parZip
operator.
The goal of Arrow is to make all its functional DSLs and constructs interchangeable.phldavies
04/29/2022, 1:44 PMeffect { }
block 🙂 - I assume most/all usage of the old computation blocks will still work in 11.x but I’d rather switch them all to effect
as part of upgradingsimon.vergauwen
04/29/2022, 1:44 PMeither {}
. Which you can migrate by finding and replacing arrow.core.computation
to arrow.core.continuation
and the API usage will not break anywere.simon.vergauwen
04/29/2022, 1:45 PMsimon.vergauwen
04/29/2022, 1:45 PMphldavies
04/29/2022, 1:48 PMResource.tap
is broken (removed the unnecessary <B>
type argument, which was seemingly always required to invoke it) I had a few .tap<Nothing> { … }
that would need updating.simon.vergauwen
04/29/2022, 1:48 PMsimon.vergauwen
04/29/2022, 1:49 PM.tap<Nothing> {
to .tap {
simon.vergauwen
04/29/2022, 1:50 PMphldavies
04/29/2022, 3:04 PM@Deprecated(message = "Use `tap(f)`", replaceWith = ReplaceWith(expression = "tap(f)"))
public inline fun <B> tap(marker: Nothing? = null, f: suspend (A) -> Unit): Resource<A> = tap(f)
would work for maintaining source compatibility without impacting binary compatibility 🤔phldavies
04/29/2022, 3:22 PM.tap<Nothing>({ … })
I suppose.