From ed61490e0ef4830fa41f21900863c0ea6d20077e Mon Sep 17 00:00:00 2001 From: Ben Plommer Date: Tue, 13 Oct 2020 23:43:38 +0100 Subject: [PATCH] add ref and deferred to IO companion --- core/shared/src/main/scala/cats/effect/IO.scala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/shared/src/main/scala/cats/effect/IO.scala b/core/shared/src/main/scala/cats/effect/IO.scala index d4fa45ed40..08bf60cf89 100644 --- a/core/shared/src/main/scala/cats/effect/IO.scala +++ b/core/shared/src/main/scala/cats/effect/IO.scala @@ -318,6 +318,10 @@ object IO extends IOCompanionPlatform with IOLowPriorityImplicits { right: IO[B]): IO[Either[(OutcomeIO[A], FiberIO[B]), (FiberIO[A], OutcomeIO[B])]] = left.racePair(right) + def ref[A](a: A): IO[Ref[IO, A]] = IO(Ref.unsafe(a)) + + def deferred[A]: IO[Deferred[IO, A]] = IO(Deferred.unsafe) + /** * Returns the given argument if `cond` is true, otherwise `IO.Unit` * @@ -549,9 +553,9 @@ object IO extends IOCompanionPlatform with IOLowPriorityImplicits { fa: IO[A])(recover: Throwable => IO[B], bind: A => IO[B]): IO[B] = fa.redeemWith(recover, bind) - override def ref[A](a: A): IO[Ref[IO, A]] = IO(Ref.unsafe(a)) + override def ref[A](a: A): IO[Ref[IO, A]] = IO.ref(a) - override def deferred[A]: IO[Deferred[IO, A]] = IO(Deferred.unsafe) + override def deferred[A]: IO[Deferred[IO, A]] = IO.deferred } implicit def asyncForIO: kernel.Async[IO] = _asyncForIO