v2.0.0-beta10
2.0.0-beta10 - 2023-07-15
New Feature
-
Add
fromEffect(fa: => F[A]): F[A]
toFxCtor
andFx
(#524)Fx[IO].fromEffect(IO(1)) // IO[Int] FxCtor[IO].fromEffect(IO(1)) // IO[Int]
-
Add
make[A](fa: => F[A])(release: A => F[Unit]): ReleasableResource[F, A]
toResourceMaker[F[*]]
(#527)def make[A](fa: => F[A])(release: A => F[Unit]): ReleasableResource[F, A]
-
Try
val resourceMaker = ResourceMaker.usingResourceMaker resourceMaker .make(Try(new SomeResource()))(a => Try(a.release())) // ReleasableResource[Try, SomeResource] .use { someResource => // do something with someResource Try(result) // Try[ResultType] } // Try[ResultType]
-
Future
val resourceMaker = ResourceMaker.futureResourceMaker resourceMaker .make(Future(new SomeResource()))(a => Future(a.release())) // ReleasableResource[Future, SomeResource] .use { someResource => // do something with someResource Future.successful(result) // Future[ResultType] } // Future[ResultType]
-
Cats Effect 2
val resourceMaker = Ce2ResourceMaker.withResource resourceMaker .make(IO(new SomeResource()))(a => IO(a.release())) // ReleasableResource[IO, SomeResource] .use { someResource => // do something with someResource IO.pure(result) // IO[ResultType] } // IO[ResultType]
-
Cats Effect 3
val resourceMaker = Ce3ResourceMaker.withResource resourceMaker .make(IO(new SomeResource()))(a => IO(a.release())) // ReleasableResource[IO, SomeResource] .use { someResource => // do something with someResource IO.pure(result) // IO[ResultType] } // IO[ResultType]
-
-
Add
pure[A](a: A)
andeval[A](fa: F[A])
toResourceMaker
(#534)trait ResourceMaker[F[*]] { ... def pure[A](a: A): ReleasableResource[F, A] def eval[A](fa: F[A]): ReleasableResource[F, A] }
-
Add
ReleasableResource.pure
(#542)ReleasableResource.pure(resource: A): ReleasableResource[F, A]
So
A
doesn't have to beAutoCloseable
as it's just a pure value. -
Add
ReleasableResource.map
andReleasableResource.flatMap
(#544)ReleasableResource.map(f: A => B) ReleasableResource.flatMap(f: A => ReleasableResource[F, B])
-
Add
Functor
type-class forReleasableResource
(#548) -
Add
Applicative
type-class forReleasableResource
(#550)
Changes
-
Remove unnecessary re-evaluation of
ResourceMaker
(#529)The following
ResourceMaker
constructor method is justval
now.effectie.resource.ResourceMaker.usingResourceMaker
-
Rename
withResource
inCe2ResourceMaker
andCe3ResourceMaker
tomaker
(#530) -
Move
ResourceMaker
andReleasableResource
toeffectie-cats
(#546)Having
ReleasableResource
ineffectie-cats
is required to haveFunctor
andMonad
type-classes.