Releases: kevin-lee/effectie
v2.0.0-beta14
2.0.0-beta14 - 2024-01-12
New Feature
- Add
effectie-time
module (#601) - [
effectie-time
] AddTimeSource
(#602)TimeSource[F].currentTime() TimeSource[F].realTime TimeSource[F].realTimeTo TimeSource[F].monotonic TimeSource[F].monotonicTo TimeSource[F].timeSpent(F[A])
- [
effectie-time
] AddApproxFiniteDuration
andsyntax
(#603)import scala.concurrent.duration._ import effectie.time.syntax._ 5.seconds +- 2.seconds // ApproxFiniteDuration(5.seconds, 2.seconds) 3.seconds.isWithIn(5.seconds +- 2.seconds) // Boolean = true 7.seconds.isWithIn(5.seconds +- 2.seconds) // Boolean = true 2.seconds.isWithIn(5.seconds +- 2.seconds) // Boolean = false 8.seconds.isWithIn(5.seconds +- 2.seconds) // Boolean = false
- Add
effectie-cats-effect2-time
effectie-time-cats-effect2
(#607) - [
effectie-cats-effect2-time
] AddTimeSource
withClock
fromcats-effect
2 (#608) - Add
effectie-cats-effect3-time
effectie-time-cats-effect3
(#610) - [
effectie-cats-effect3-time
] AddTimeSource
withClock
fromcats-effect
3 (#611) - Rename
effectie-cats-effect2-time
toeffectie-time-cats-effect2
andeffectie-cats-effect3-time
toeffectie-time-cats-effect3
(#615)
v2.0.0-beta13
2.0.0-beta13 - 2023-10-01
Changes
CanHandleError[Future]
andCanRecover[Future]
should useFuture
'srecover
andrecoverWith
. (#584)CanHandleError[Try].handleNonFatal
andCanRecover[Try].recoverFromNonFatal
should useTry
'srecover
(#586)
New Feature
-
rethrowIfLeft
andrethrowTIfLeft
syntax
forF[Either[A, B]]
andEitherT[F, A, B]
(#588)val fa: IO[Either[Throwable, Int]] = pureOf[IO](Right(1)) fa.rethrowIfLeft // IO[Int] = IO(1)
val fa: IO[Either[Throwable, Int]] = pureOf[IO](Left(new RuntimeException("Error"))) fa.rethrowIfLeft // IO[Int] = RaiseError(RuntimeException("ERROR"))
val fa: EitherT[IO, Throwable, Int] = pureOf[IO](Right(1)).eitherT fa.rethrowTIfLeft // IO[Int] = IO(1)
val fa: EitherT[IO, Throwable, Int] = pureOf[IO](Left(new RuntimeException("Error"))).eitherT fa.rethrowTIfLeft // IO[Int] = RaiseError(RuntimeException("ERROR"))
v2.0.0-beta12
2.0.0-beta12 - 2023-09-09
New Features
-
Add
CanRestart
for retryingF[A]
(#566)trait CanRestart[F[*]] { def restartWhile[A](fa: F[A])(p: A => Boolean): F[A] def restartUntil[A](fa: F[A])(p: A => Boolean): F[A] def restartOnError[A](fa: F[A])(maxRetries: Long): F[A] def restartOnErrorIfTrue[A](fa: F[A])(p: Throwable => Boolean): F[A] }
-
Add instances of
CanCatch
,CanHandleError
,CanRecover
,FromFuture
,Fx
andFxCtor
withSync
andAsync
(#568)So it can be done like this with the
effectie.instances.ce2.f
andeffectie.instances.ce3.f
packages.def foo[F[*]: Fx](n: Int): F[Int] = Fx[F].effectOf(n * 2) // Fx[F] can be satisfied with just Sync[F] like this. import effectie.instances.ce2.f.fx._ def bar[F[*]: Sync](n: Int): F[Int] = foo(n)
v2.0.0-beta11
2.0.0-beta11 - 2023-07-22
Fixed
- Fix the comments of the
deprecated
methods inCe2ResourceMaker
andCe3ResourceMaker
(#559)Ce2ResourceMaker
:Please use withResource instead
=>Please use Ce2ResourceMaker.maker instead
Ce3ResourceMaker
:Please use withResource instead
=>Please use Ce3ResourceMaker.maker instead
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.
v2.0.0-beta9
v2.0.0-beta8
2.0.0-beta8 - 2023-03-07
Changes
-
Remove unused implicit params (#497)
def catchNonFatal[A]( f: PartialFunction[Throwable, A] )( implicit canCatch: CanCatch[F], fxCtor: FxCtor[F], // <= This is unused ): F[Either[A, B]] = canCatch.catchNonFatal[A, B](fb())(f)
The
implicit
paramfxCtor: FxCtor[F]
has been removed. -
Rename
ConsoleEffect
toConsoleFx
(#499) -
Move
flatMapFa
fromCanCatch
toFxCtor
(#501)def flatMapFa[A, B](fa: F[A])(f: A => F[B]): F[B]
-
Move
FxCtor
from instance creation ofConsoleFx
to eachConsoleFx
method param (#504)implicit def consoleFxF[F[*]: FxCtor: FlatMap]: ConsoleFx[F] = ...
to
trait ConsoleFx[F[*]] { def readLn(implicit fxCtor: FxCtor[F]): F[String] def readPassword(implicit fxCtor: FxCtor[F]): F[Array[Char]] def putStr(value: String)(implicit fxCtor: FxCtor[F]): F[Unit] def putStrLn(value: String)(implicit fxCtor: FxCtor[F]): F[Unit] def putErrStr(value: String)(implicit fxCtor: FxCtor[F]): F[Unit] def putErrStrLn(value: String)(implicit fxCtor: FxCtor[F]): F[Unit] def readYesNo(prompt: String)(implicit fxCtor: FxCtor[F]): F[YesNo] }
-
ConsoleFx
instance should not depend on cats (Monad
) (#505)Instead, it depends on
FxCtor
now.
v2.0.0-beta7
2.0.0-beta7 - 2023-02-25
New Features
- Add
pureOfOption
,pureOfSome
,pureOfNone
,pureOfRight
andpureOfLeft
toFxCtor
andFx
(#488)Fx[F].pureOfOption[A](a: A): F[Option[A]]
Fx[F].pureOfSome[A](a: A): F[Option[A]]
Fx[F].pureOfNone[A]: F[Option[A]]
Fx[F].pureOfRight[A][B](b: B): F[Either[A, B]]
Fx[F].pureOfLeft[B][A](a: A): F[Either[A, B]]
Fix
- Fix typo in the missing
implicit
instance messages (#489)
v2.0.0-beta6
2.0.0-beta6 - 2023-02-11
Change
-
Remove
implicit fxCtor: FxCtor[F]
param from the catch methods inCanCatch
(#480)The following methods in
CanCatch
def catchNonFatal[A, B]( fb: => F[B] )( f: PartialFunction[Throwable, A] )( implicit fxCtor: FxCtor[F] ): F[Either[A, B]] def catchNonFatalEither[A, AA >: A, B]( fab: => F[Either[A, B]] )( f: PartialFunction[Throwable, AA] )( implicit fxCtor: FxCtor[F] ): F[Either[AA, B]]
have been changed to
def catchNonFatal[A, B]( fb: => F[B] )( f: PartialFunction[Throwable, A] ): F[Either[A, B]] def catchNonFatalEither[A, AA >: A, B]( fab: => F[Either[A, B]] )( f: PartialFunction[Throwable, AA] ): F[Either[AA, B]]
v2.0.0-beta5
2.0.0-beta5 - 2023-01-14
New Features
-
Add
ResourceMaker
(#468)ResourceMaker[F].forAutoCloseable[A <: AutoCloseable](fa: F[A]): ReleasableResource[F, A]
import effectie.resource.ResourceMaker ResourceMaker.usingResourceMaker // ResourceMaker[Try] ResourceMaker.futureResourceMaker(implicit ec: ExecutionContext) // ResourceMaker[Future]
import effectie.resource.Ce2ResourceMaker Ce2ResourceMaker.forAutoCloseable // ResourceMaker[F] where F[*]: Sync: BracketThrow
import effectie.resource.Ce3Resource Ce3Resource.forAutoCloseable // ResourceMaker[F] where F[*]: Sync: MonadCancelThrow
Internal Housekeeping
cats-effect
3.3.5
=>3.3.14