2.5.0 - 2026-08-04
New Features
Redesign ReleasableResource as a pure description ADT with the UseResource interpreter (#705)
ReleasableResource[F[*], +A] is now a sealed, covariant, constraint-free data type describing acquisition and release. It follows effectie's own Fx pattern: one shared contract with per-effect-system instances, so the same code behaves identically for Try, Future, cats-effect 2/3 IO, and Monix Task.
- Constructors (no typeclass needed):
ReleasableResource.pure/eval/make/makeCase/fromAutoCloseable(requiresFxCtor[F]) /raiseError/unit - Combinators:
map,flatMap,evalMap,evalTap,flatTap,onFinalize,onFinalizeCase,attempt,handleErrorWith,surround,use_ ReleasableResource.ExitCase(Completed/Errored/Canceled): release actions registered withmakeCase/onFinalizeCaseobserve how the scope ended.Canceledonly occurs for cancellable effect systems (cats-effect, Monix).- Constraint-free
MonadError[ReleasableResource[F, *], Throwable]in the companion object — noResourceMakerrequired, with a stack-safetailRecM(replaces the previousResourceMaker-gatedApplicativeinstance).
New UseResource[F] typeclass — the capability of running a ReleasableResource
Running .use(...) now requires an implicit effectie.resource.UseResource[F]:
Try/Future: provided automatically (companion object instances;Futureneeds an implicitExecutionContext)- cats-effect 3:
import effectie.instances.ce3.resource._(IO) orimport effectie.instances.ce3.f.resource._(anyF[_]: MonadCancelThrow) - cats-effect 2:
import effectie.instances.ce2.resource._(IO) orimport effectie.instances.ce2.f.resource._(anyF[_]: BracketThrow) - Monix 3:
import effectie.instances.monix3.resource._(Task) - Scala 3: use
.giveninstead of._(e.g.import effectie.instances.ce3.resource.given), or import the instance by name (e.g.ioUseResource,taskUseResource) which works in both Scala 2 and Scala 3
The cats-effect and Monix instances interpret the description through a real cats.effect.Resource, so bracketing and cancellation safety are exactly cats-effect's. There is deliberately no generic fallback instance, so cancellable effect types can never silently lose cancellation safety.
cats-effect interop
Ce3UseResource.toCatsEffectResource/Ce3UseResource.fromCatsEffectResource— two-way conversion withcats.effect.Resource(cats-effect 3)Ce2UseResource.toCatsEffectResource/Ce2UseResource.fromCatsEffectResource— the same for cats-effect 2 (note: CE2'sallocatedexposes no exit case, so a wrapped foreign finalizer cannot observe it)
Behavior Fixes
- Lazy acquisition: constructing a
ReleasableResourceno longer performs any effects forTry/Future(previously the resource was acquired eagerly at construction, leaking when never used). Acquisition now happens on eachuse, and a seconduseacquires a fresh resource instead of reusing a closed one. - Release errors are no longer swallowed: previously
Trydiscarded them silently andFutureprinted to stdout. Now, whenusesucceeded but release fails, the release error is raised; when both fail, theuseerror is raised with the release error attached viaaddSuppressed(cats-effect parity). Futureresource leak fixed: a synchronous throw inside theusefunction now still releases the resource.ResourceMaker[F].evalfor cats-effect now maps toResource.evalsemantics (previously it created an uncancelable no-op-release acquisition).
Deprecations
ResourceMaker and its instances (ResourceMaker.tryResourceMaker, ResourceMaker.futureResourceMaker, Ce2ResourceMaker.maker, Ce3ResourceMaker.maker), the old ReleasableResource companion constructors (usingResource, usingResourceFromTry, futureResource, makeTry, pureTry, makeFuture, pureFuture), and the Ce2Resource / Ce3Resource constructor objects are deprecated but keep working as thin shims over the new API. Each deprecation message contains the exact replacement and the UseResource import to add.
Breaking Changes
ReleasableResourceis nowsealed; the public traitsCe2ResourceandCe3Resourceare removed (their companionobjects remain as deprecated constructors)..use(...)requires an implicitUseResource[F]:Try/Futureusers need no change; cats-effect / Monix users add one import (a descriptiveimplicitNotFoundmessage shows exactly which).- The
Applicative[ReleasableResource[F, *]]instance requiringResourceMaker[F]is replaced by the constraint-freeMonadErrorinstance. Try/Futureresource semantics intentionally changed as listed under Behavior Fixes.
What's Changed
- Close #705: Redesign ReleasableResource as a pure description ADT with the UseResource interpreter by @kevin-lee in #706
- Fix
IORuntimefile-descriptor leak ineffectie-cats-effect3tests by @kevin-lee in #707 - Add missing tests for the
UseResourceinterpreter andReleasableResourceADT by @kevin-lee in #708 - Verify resources are actually closed across
Try,Futureand cats-effect by @kevin-lee in #709 - effectie v2.5.0 by @kevin-lee in #710
Full Changelog: v2.4.0...v2.5.0