I understood ManagedT as a helper of sorts to ease...
# arrow-contributors
j
I understood ManagedT as a helper of sorts to ease acquisition of multiple resources that guarantees freeing in correct order. You can do the same with bracket up to some limit. ManagedT makes patterns like
List<Resource>.traverse(ManagedT.applicative()) { ManagedT({ acquire(it) }, { release(it) }) }.invoke { l: List<AcquiredResource> -> { // do useful stuff } }
possible. Also monadic acquisiton of multiple resources without deeply nesting bracket syntax is a thing. I think as soon as you need to acquire and release 2 or more resources and those depend on each other you are better of with ManagedT over Bracket, as it just composes better.