Repository: 7mind/izumi
Pull request #931 (2020-03-06 15:21:51)

Update to ZIO RC18

codecov-io: # [Codecov](https://codecov.io/gh/7mind/izumi/pull/931?src=pr&el=h1) Report
> Merging [#931](https://codecov.io/gh/7mind/izumi/pull/931?src=pr&el=desc) into [develop](https://codecov.io/gh/7mind/izumi/commit/e89fae09221e33a423f9b1830be161deee4bfd08?src=pr&el=desc) will **increase** coverage by `0.14%`.
> The diff coverage is `24.39%`.

[![Impacted file tree graph](https://codecov.io/gh/7mind/izumi/pull/931/graphs/tree.svg?width=650&token=77pa3UU1Je&height=150&src=pr)](https://codecov.io/gh/7mind/izumi/pull/931?src=pr&el=tree)

```diff
@@             Coverage Diff             @@
##           develop     #931      +/-   ##
===========================================
+ Coverage    58.19%   58.33%   +0.14%     
===========================================
  Files          350      352       +2     
  Lines         7640     7637       -3     
  Branches       451      448       -3     
===========================================
+ Hits          4446     4455       +9     
+ Misses        3194     3182      -12
```


| [Impacted Files](https://codecov.io/gh/7mind/izumi/pull/931?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [.../src/main/scala/izumi/functional/bio/package.scala](https://codecov.io/gh/7mind/izumi/pull/931/diff?src=pr&el=tree#diff-ZnVuZGFtZW50YWxzL2Z1bmRhbWVudGFscy1iaW8vc3JjL21haW4vc2NhbGEvaXp1bWkvZnVuY3Rpb25hbC9iaW8vcGFja2FnZS5zY2FsYQ==) | `11.11% <ø> (ø)` | :arrow_up: |
| [...n/scala/izumi/distage/docker/DockerContainer.scala](https://codecov.io/gh/7mind/izumi/pull/931/diff?src=pr&el=tree#diff-ZGlzdGFnZS9kaXN0YWdlLWZyYW1ld29yay1kb2NrZXIvc3JjL21haW4vc2NhbGEvaXp1bWkvZGlzdGFnZS9kb2NrZXIvRG9ja2VyQ29udGFpbmVyLnNjYWxh) | `0.9% <ø> (ø)` | :arrow_up: |
| [...c/main/scala/izumi/functional/bio/BIOPromise.scala](https://codecov.io/gh/7mind/izumi/pull/931/diff?src=pr&el=tree#diff-ZnVuZGFtZW50YWxzL2Z1bmRhbWVudGFscy1iaW8vc3JjL21haW4vc2NhbGEvaXp1bWkvZnVuY3Rpb25hbC9iaW8vQklPUHJvbWlzZS5zY2FsYQ==) | `0% <ø> (ø)` | :arrow_up: |
| [...la/izumi/distage/model/definition/DIResource.scala](https://codecov.io/gh/7mind/izumi/pull/931/diff?src=pr&el=tree#diff-ZGlzdGFnZS9kaXN0YWdlLWNvcmUtYXBpL3NyYy9tYWluL3NjYWxhL2l6dW1pL2Rpc3RhZ2UvbW9kZWwvZGVmaW5pdGlvbi9ESVJlc291cmNlLnNjYWxh) | `41.41% <0%> (-0.43%)` | :arrow_down: |
| [...o/src/main/scala/izumi/functional/bio/BIORef.scala](https://codecov.io/gh/7mind/izumi/pull/931/diff?src=pr&el=tree#diff-ZnVuZGFtZW50YWxzL2Z1bmRhbWVudGFscy1iaW8vc3JjL21haW4vc2NhbGEvaXp1bWkvZnVuY3Rpb25hbC9iaW8vQklPUmVmLnNjYWxh) | `0% <0%> (ø)` | :arrow_up: |
| [...ain/scala/izumi/functional/bio/BIOPrimitives.scala](https://codecov.io/gh/7mind/izumi/pull/931/diff?src=pr&el=tree#diff-ZnVuZGFtZW50YWxzL2Z1bmRhbWVudGFscy1iaW8vc3JjL21haW4vc2NhbGEvaXp1bWkvZnVuY3Rpb25hbC9iaW8vQklPUHJpbWl0aXZlcy5zY2FsYQ==) | `14.28% <0%> (-5.72%)` | :arrow_down: |
| [...main/scala/izumi/functional/bio/BIOSemaphore.scala](https://codecov.io/gh/7mind/izumi/pull/931/diff?src=pr&el=tree#diff-ZnVuZGFtZW50YWxzL2Z1bmRhbWVudGFscy1iaW8vc3JjL21haW4vc2NhbGEvaXp1bWkvZnVuY3Rpb25hbC9iaW8vQklPU2VtYXBob3JlLnNjYWxh) | `0% <0%> (ø)` | :arrow_up: |
| [...umi/distage/effect/modules/ZIODIEffectModule.scala](https://codecov.io/gh/7mind/izumi/pull/931/diff?src=pr&el=tree#diff-ZGlzdGFnZS9kaXN0YWdlLWZyYW1ld29yay9zcmMvbWFpbi9zY2FsYS9penVtaS9kaXN0YWdlL2VmZmVjdC9tb2R1bGVzL1pJT0RJRWZmZWN0TW9kdWxlLnNjYWxh) | `100% <100%> (ø)` | :arrow_up: |
| [...rc/main/scala/zio/compatrc18/zio\_succeed\_Now.scala](https://codecov.io/gh/7mind/izumi/pull/931/diff?src=pr&el=tree#diff-ZnVuZGFtZW50YWxzL2Z1bmRhbWVudGFscy1iaW8vc3JjL21haW4vc2NhbGEvemlvL2NvbXBhdHJjMTgvemlvX3N1Y2NlZWRfTm93LnNjYWxh) | `100% <100%> (ø)` | |
| [...in/scala/zio/clock/compatrc18/zio\_Clock\_Live.scala](https://codecov.io/gh/7mind/izumi/pull/931/diff?src=pr&el=tree#diff-ZnVuZGFtZW50YWxzL2Z1bmRhbWVudGFscy1iaW8vc3JjL21haW4vc2NhbGEvemlvL2Nsb2NrL2NvbXBhdHJjMTgvemlvX0Nsb2NrX0xpdmUuc2NhbGE=) | `22.22% <22.22%> (ø)` | |
| ... and [6 more](https://codecov.io/gh/7mind/izumi/pull/931/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/7mind/izumi/pull/931?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/7mind/izumi/pull/931?src=pr&el=footer). Last update [e89fae0...8966bc7](https://codecov.io/gh/7mind/izumi/pull/931?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/DIResource.scala b/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/DIResource.scala
index 0a19185b6..06a7eb704 100644
--- a/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/DIResource.scala
+++ b/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/DIResource.scala
@@ -532,6 +532,14 @@ object DIResource {
     ProviderMagnet.lift(fromZIO(managed))
   }
 
+  /**
+    * Allows you to bind [[zio.ZManaged]]-based constructors in `ModuleDef`:
+    */
+  // workaround for inference issues with `E=Nothing`, scalac error: Couldn't find Tag[FromZIO[Any, E, Clock]] when binding ZManaged[Any, Nothing, Clock]
+  implicit final def providerFromZIONothing[R, A](managed: => ZManaged[R, Nothing, A])(implicit tag: Tag[DIResource.FromZIO[R, Nothing, A]]): ProviderMagnet[DIResource.FromZIO[R, Nothing, A]] = {
+    ProviderMagnet.lift(fromZIO(managed))
+  }
+
   /** Support binding various FP libraries' Resource types in `.fromResource` */
   trait AdaptProvider[A] {
     type Out
diff --git a/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/dsl/ModuleDefDSL.scala b/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/dsl/ModuleDefDSL.scala
index 54e95a5c0..9bf59c53d 100644
--- a/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/dsl/ModuleDefDSL.scala
+++ b/distage/distage-core-api/src/main/scala/izumi/distage/model/definition/dsl/ModuleDefDSL.scala
@@ -96,7 +96,7 @@ trait ModuleDefDSL
 object ModuleDefDSL {
 
   trait MakeDSLBase[T, AfterBind] {
-    final def from[I <: T: Tag: AnyConstructor]: AfterBind =
+    final def from[I <: T: AnyConstructor]: AfterBind =
       from(AnyConstructor[I].provider)
 
     final def from[I <: T: Tag](function: => I): AfterBind =
@@ -174,8 +174,8 @@ object ModuleDefDSL {
       *
       * @see [[izumi.distage.model.reflection.macros.ProviderMagnetMacro]]
       */
-    final def from[I <: T: Tag](function: ProviderMagnet[I]): AfterBind =
-      bind(ImplDef.ProviderImpl(SafeType.get[I], function.get))
+    final def from[I <: T](function: ProviderMagnet[I]): AfterBind =
+      bind(ImplDef.ProviderImpl(function.get.ret, function.get))
 
     /**
       * Bind by reference to another bound key
@@ -213,7 +213,7 @@ object ModuleDefDSL {
       bind(ImplDef.EffectImpl(SafeType.get[I], SafeType.getK[F], ImplDef.InstanceImpl(SafeType.get[F[I]], instance)))
 
     final def fromEffect[F[_]: TagK, I <: T: Tag](function: ProviderMagnet[F[I]]): AfterBind =
-      bind(ImplDef.EffectImpl(SafeType.get[I], SafeType.getK[F], ImplDef.ProviderImpl(SafeType.get[F[I]], function.get)))
+      bind(ImplDef.EffectImpl(SafeType.get[I], SafeType.getK[F], ImplDef.ProviderImpl(function.get.ret, function.get)))
 
     /**
       * Bind to result of executing an effect bound to a key at `F[I]`
@@ -326,7 +326,7 @@ object ModuleDefDSL {
     final def addValue[I <: T: Tag](instance: I)(implicit pos: CodePositionMaterializer): AfterAdd =
       appendElement(ImplDef.InstanceImpl(SafeType.get[I], instance), pos)
 
-    final def add[I <: T: Tag](function: ProviderMagnet[I])(implicit pos: CodePositionMaterializer): AfterAdd =
+    final def add[I <: T](function: ProviderMagnet[I])(implicit pos: CodePositionMaterializer): AfterAdd =
       appendElement(ImplDef.ProviderImpl(function.get.ret, function.get), pos)
 
     /**
@@ -373,7 +373,7 @@ object ModuleDefDSL {
     final def addSetValue[I <: Set[_ <: T]: Tag](instance: I)(implicit pos: CodePositionMaterializer): AfterMultiAdd =
       multiSetAdd(ImplDef.InstanceImpl(SafeType.get[I], instance), pos)
 
-    final def addSet[I <: Set[_ <: T]: Tag](function: ProviderMagnet[I])(implicit pos: CodePositionMaterializer): AfterMultiAdd =
+    final def addSet[I <: Set[_ <: T]](function: ProviderMagnet[I])(implicit pos: CodePositionMaterializer): AfterMultiAdd =
       multiSetAdd(ImplDef.ProviderImpl(function.get.ret, function.get), pos)
 
     final def refSet[I <: Set[_ <: T]: Tag](implicit pos: CodePositionMaterializer): AfterAdd =
@@ -392,7 +392,7 @@ object ModuleDefDSL {
       appendElement(ImplDef.EffectImpl(SafeType.get[I], SafeType.getK[F], ImplDef.InstanceImpl(SafeType.get[F[I]], instance)), pos)
 
     final def addEffect[F[_]: TagK, I <: T: Tag](function: ProviderMagnet[F[I]])(implicit pos: CodePositionMaterializer): AfterAdd =
-      appendElement(ImplDef.EffectImpl(SafeType.get[I], SafeType.getK[F], ImplDef.ProviderImpl(SafeType.get[F[I]], function.get)), pos)
+      appendElement(ImplDef.EffectImpl(SafeType.get[I], SafeType.getK[F], ImplDef.ProviderImpl(function.get.ret, function.get)), pos)
 
     final def refEffect[F[_]: TagK, I <: T: Tag](implicit pos: CodePositionMaterializer): AfterAdd =
       appendElement(ImplDef.EffectImpl(SafeType.get[I], SafeType.getK[F], ImplDef.ReferenceImpl(SafeType.get[F[I]], DIKey.get[F[I]], weak = false)), pos)
diff --git a/distage/distage-framework-docker/src/main/scala/izumi/distage/docker/DockerContainer.scala b/distage/distage-framework-docker/src/main/scala/izumi/distage/docker/DockerContainer.scala
index 8cca08143..f21abde87 100644
--- a/distage/distage-framework-docker/src/main/scala/izumi/distage/docker/DockerContainer.scala
+++ b/distage/distage-framework-docker/src/main/scala/izumi/distage/docker/DockerContainer.scala
@@ -188,7 +188,7 @@ object DockerContainer {
               .withStatusFilter(List("running").asJava)
               .exec()
           } catch {
-            case c: ConnectException =>
+            case c: Throwable =>
               throw new IntegrationCheckException(Seq(ResourceCheck.ResourceUnavailable(c.getMessage, Some(c))))
           }
         }.map(_.asScala.toList.sortBy(_.getId))
diff --git a/distage/distage-framework/src/main/scala/izumi/distage/effect/modules/ZIODIEffectModule.scala b/distage/distage-framework/src/main/scala/izumi/distage/effect/modules/ZIODIEffectModule.scala
index a99df93c2..3191742d1 100644
--- a/distage/distage-framework/src/main/scala/izumi/distage/effect/modules/ZIODIEffectModule.scala
+++ b/distage/distage-framework/src/main/scala/izumi/distage/effect/modules/ZIODIEffectModule.scala
@@ -57,7 +57,8 @@ trait ZIODIEffectModule extends ModuleDef {
   make[BIOTemporal[IO]].from {
     r: zio.clock.Clock => BIOTemporalInstances.BIOTemporalZio[Any](r)
   }
-  make[zio.clock.Clock].fromValue(zio.clock.Clock.Live)
+
+  make[zio.clock.Clock].from(zio.clock.compatrc18.zio_Clock_Live.live)
 
   make[zio.Runtime[Any]].from((_: ZIORunner).runtime)
   make[BIORunner[IO]].using[ZIORunner]
diff --git a/fundamentals/fundamentals-bio/.js/src/main/scala/izumi/functional/bio/__PlatformSpecific.scala b/fundamentals/fundamentals-bio/.js/src/main/scala/izumi/functional/bio/__PlatformSpecific.scala
new file mode 100644
index 000000000..3f8c77b7c
--- /dev/null
+++ b/fundamentals/fundamentals-bio/.js/src/main/scala/izumi/functional/bio/__PlatformSpecific.scala
@@ -0,0 +1,11 @@
+package izumi.functional.bio
+
+import java.util.concurrent.CompletionStage
+
+import zio.IO
+
+private[bio] object __PlatformSpecific {
+  @inline def fromFutureJava[A](@deprecated("x", "x") javaFuture: => CompletionStage[A]): IO[Throwable, A] = {
+    throw new RuntimeException("No CompletionStage on Scala.js!")
+  }
+}
diff --git a/fundamentals/fundamentals-bio/.jvm/src/main/scala/izumi/functional/bio/BlockingIO3.scala b/fundamentals/fundamentals-bio/.jvm/src/main/scala/izumi/functional/bio/BlockingIO3.scala
index b7590ea33..006652adf 100644
--- a/fundamentals/fundamentals-bio/.jvm/src/main/scala/izumi/functional/bio/BlockingIO3.scala
+++ b/fundamentals/fundamentals-bio/.jvm/src/main/scala/izumi/functional/bio/BlockingIO3.scala
@@ -4,7 +4,7 @@ import java.util.concurrent.ThreadPoolExecutor
 
 import zio.blocking.Blocking
 import zio.internal.Executor
-import zio.{IO, UIO, ZIO}
+import zio.{Has, IO, ZIO}
 
 trait BlockingIO3[F[_, _, _]] extends BlockingIOInstances {
 
@@ -36,36 +36,33 @@ object BlockingIOInstances extends LowPriorityBlockingIOInstances {
 
   def BlockingZIO3FromThreadPool(blockingPool: ThreadPoolExecutor): BlockingIO3[ZIO] = {
     val executor = Executor.fromThreadPoolExecutor(_ => Int.MaxValue)(blockingPool)
-    val blocking = new Blocking {
-      override val blocking: Blocking.Service[Any] = new Blocking.Service[Any] {
-        override val blockingExecutor: ZIO[Any, Nothing, Executor] = UIO.succeed(executor)
-      }
+    val blocking: Blocking.Service = new Blocking.Service {
+      override val blockingExecutor: Executor = executor
     }
-    blockingIOZIO3Blocking(blocking)
+    blockingIOZIO3Blocking(Has(blocking))
   }
 
   // FIXME: bad encoding for lifting to 2-parameters...
-  implicit def blockingIOZIOBlocking[R](implicit serviceBlocking: Blocking): BlockingIO[ZIO[R, +?, +?]] = {
-    blockingIOZIO3Blocking(serviceBlocking).asInstanceOf[BlockingIO[ZIO[R, +?, +?]]]
+  implicit def blockingIOZIOBlocking[R](implicit blocking: Blocking): BlockingIO[ZIO[R, +?, +?]] = {
+    blockingIOZIO3Blocking(blocking).asInstanceOf[BlockingIO[ZIO[R, +?, +?]]]
   }
 
-  implicit final def blockingIOZIO3Blocking(implicit serviceBlocking: Blocking): BlockingIO3[ZIO] = new BlockingIO3[ZIO] {
-    override def shiftBlocking[R, E, A](f: ZIO[R, E ,A]): ZIO[R, E, A] = serviceBlocking.blocking.blocking(f)
-    override def syncBlocking[A](f: => A): ZIO[Any, Throwable, A] = serviceBlocking.blocking.blocking(IO(f))
-    override def syncInterruptibleBlocking[A](f: => A): ZIO[Any, Throwable, A] = serviceBlocking.blocking.effectBlocking(f)
+  implicit final def blockingIOZIO3Blocking(implicit blocking: Blocking): BlockingIO3[ZIO] = new BlockingIO3[ZIO] {
+    val b: Blocking.Service = blocking.get
+    override def shiftBlocking[R, E, A](f: ZIO[R, E ,A]): ZIO[R, E, A] = b.blocking(f)
+    override def syncBlocking[A](f: => A): ZIO[Any, Throwable, A] = b.blocking(IO(f))
+    override def syncInterruptibleBlocking[A](f: => A): ZIO[Any, Throwable, A] = b.effectBlocking(f)
   }
 }
 
 trait LowPriorityBlockingIOInstances {
   type ZIOBlocking = { type l[-R, +E, +A] = ZIO[R with Blocking, E, A] }
 
-  implicit def blockingIOZIOR[R]: BlockingIO[ZIO[R with Blocking, +?, +?]] = {
-    blockingIOZIO3R.asInstanceOf[BlockingIO[ZIO[R with Blocking, +?, +?]]]
-  }
+  implicit def blockingIOZIOR[R]: BlockingIO[ZIO[R with Blocking, +?, +?]] = blockingIOZIO3R.asInstanceOf[BlockingIO[ZIO[R with Blocking, +?, +?]]]
 
-  implicit final def blockingIOZIO3R: BlockingIO3[ZIOBlocking#l] = new BlockingIO3[ZIOBlocking#l] {
-    override def shiftBlocking[R, E, A](f: ZIO[R with Blocking, E, A]): ZIO[R with Blocking, E, A] = ZIO.accessM(_.blocking.blocking(f))
-    override def syncBlocking[A](f: => A): ZIO[Blocking, Throwable, A] = ZIO.accessM(_.blocking.blocking(IO(f)))
-    override def syncInterruptibleBlocking[A](f: => A): ZIO[Blocking, Throwable, A] = ZIO.accessM(_.blocking.effectBlocking(f))
+  implicit final val blockingIOZIO3R: BlockingIO3[ZIOBlocking#l] = new BlockingIO3[ZIOBlocking#l] {
+    override def shiftBlocking[R, E, A](f: ZIO[R with Blocking, E, A]): ZIO[R with Blocking, E, A] = zio.blocking.blocking(f)
+    override def syncBlocking[A](f: => A): ZIO[Blocking, Throwable, A] = zio.blocking.effectBlocking(f)
+    override def syncInterruptibleBlocking[A](f: => A): ZIO[Blocking, Throwable, A] = zio.blocking.effectBlockingInterrupt(f)
   }
 }
diff --git a/fundamentals/fundamentals-bio/.jvm/src/main/scala/izumi/functional/bio/__PlatformSpecific.scala b/fundamentals/fundamentals-bio/.jvm/src/main/scala/izumi/functional/bio/__PlatformSpecific.scala
new file mode 100644
index 000000000..ce6df1c3f
--- /dev/null
+++ b/fundamentals/fundamentals-bio/.jvm/src/main/scala/izumi/functional/bio/__PlatformSpecific.scala
@@ -0,0 +1,10 @@
+package izumi.functional.bio
+
+import java.util.concurrent.CompletionStage
+
+import zio.{IO, ZIO}
+
+private[bio] object __PlatformSpecific {
+  @inline def fromFutureJava[A](javaFuture: => CompletionStage[A]): IO[Throwable, A] =
+    ZIO.fromCompletionStage(javaFuture)
+}
diff --git a/fundamentals/fundamentals-bio/src/main/scala/izumi/functional/bio/BIOPrimitives.scala b/fundamentals/fundamentals-bio/src/main/scala/izumi/functional/bio/BIOPrimitives.scala
index 01a9befbd..129e56234 100644
--- a/fundamentals/fundamentals-bio/src/main/scala/izumi/functional/bio/BIOPrimitives.scala
+++ b/fundamentals/fundamentals-bio/src/main/scala/izumi/functional/bio/BIOPrimitives.scala
@@ -1,6 +1,7 @@
 package izumi.functional.bio
 
-import zio.{IO, Promise, Ref, Semaphore}
+import cats.effect.concurrent.Semaphore
+import zio.{IO, Promise, Ref, Task}
 
 trait BIOPrimitives[F[+_, +_]] extends BIOPrimitivesInstances {
   def mkRef[A](a: A): F[Nothing, BIORef[F, A]]
@@ -16,7 +17,11 @@ object BIOPrimitivesInstances {
       override def mkRef[A](a: A): IO[Nothing, BIORef[IO, A]]                = Ref.make(a).map(BIORef.fromZIO)
       override def mkLatch: IO[Nothing, BIOPromise[IO, Nothing, Unit]]       = mkPromise[Nothing, Unit]
       override def mkPromise[E, A]: IO[Nothing, BIOPromise[IO, E, A]]        = Promise.make[E, A].map(BIOPromise.fromZIO)
-      override def mkSemaphore(permits: Long): IO[Nothing, BIOSemaphore[IO]] = Semaphore.make(permits).map(BIOSemaphore.fromZIO)
+      override def mkSemaphore(permits: Long): IO[Nothing, BIOSemaphore[IO]] = {
+        Semaphore[Task](permits)(catz.BIOAsyncForkToConcurrent)
+          .map(BIOSemaphore.fromCats[IO])
+          .orTerminate
+      }
     }
   }
 }
diff --git a/fundamentals/fundamentals-bio/src/main/scala/izumi/functional/bio/BIOPromise.scala b/fundamentals/fundamentals-bio/src/main/scala/izumi/functional/bio/BIOPromise.scala
index c11bc30c6..6bb06e9a4 100644
--- a/fundamentals/fundamentals-bio/src/main/scala/izumi/functional/bio/BIOPromise.scala
+++ b/fundamentals/fundamentals-bio/src/main/scala/izumi/functional/bio/BIOPromise.scala
@@ -2,7 +2,7 @@ package izumi.functional.bio
 
 import zio.{IO, Promise}
 
-trait BIOPromise[F[_, _], E, A] {
+trait BIOPromise[+F[+_, +_], E, A] {
   def await: F[E, A]
   def poll: F[Nothing, Option[F[E, A]]]
 
diff --git a/fundamentals/fundamentals-bio/src/main/scala/izumi/functional/bio/BIORef.scala b/fundamentals/fundamentals-bio/src/main/scala/izumi/functional/bio/BIORef.scala
index b868e8ed3..032634a6d 100644
--- a/fundamentals/fundamentals-bio/src/main/scala/izumi/functional/bio/BIORef.scala
+++ b/fundamentals/fundamentals-bio/src/main/scala/izumi/functional/bio/BIORef.scala
@@ -2,7 +2,7 @@ package izumi.functional.bio
 
 import zio.{IO, Ref}
 
-trait BIORef[F[_, _], A] {
+trait BIORef[+F[_, _], A] {
   def get: F[Nothing, A]
   def set(a: A): F[Nothing, Unit]
 
@@ -18,7 +18,7 @@ object BIORef {
       override def set(a: A): IO[Nothing, Unit] = ref.set(a)
 
       override def modify[B](f: A => (B, A)): IO[Nothing, B] = ref.modify(f)
-      override def update(f: A => A): IO[Nothing, A]         = ref.update(f)
-      override def update_(f: A => A): IO[Nothing, Unit]     = ref.update(f).unit
+      override def update(f: A => A): IO[Nothing, A]         = ref.updateAndGet(f)
+      override def update_(f: A => A): IO[Nothing, Unit]     = ref.update(f)
     }
 }
diff --git a/fundamentals/fundamentals-bio/src/main/scala/izumi/functional/bio/BIOSemaphore.scala b/fundamentals/fundamentals-bio/src/main/scala/izumi/functional/bio/BIOSemaphore.scala
index 1c14e3746..debafb4dd 100644
--- a/fundamentals/fundamentals-bio/src/main/scala/izumi/functional/bio/BIOSemaphore.scala
+++ b/fundamentals/fundamentals-bio/src/main/scala/izumi/functional/bio/BIOSemaphore.scala
@@ -1,9 +1,8 @@
 package izumi.functional.bio
 
-import com.github.ghik.silencer.silent
-import zio.{IO, Semaphore}
+import cats.effect.concurrent.Semaphore
 
-trait BIOSemaphore[F[_, _]] {
+trait BIOSemaphore[+F[_, _]] {
   def acquire: F[Nothing, Unit]
   def release: F[Nothing, Unit]
 
@@ -12,13 +11,12 @@ trait BIOSemaphore[F[_, _]] {
 }
 
 object BIOSemaphore {
-  @silent("deprecated")
-  def fromZIO(semaphore: Semaphore): BIOSemaphore[IO] =
-    new BIOSemaphore[IO] {
-      override def acquire: IO[Nothing, Unit] = semaphore.acquire
-      override def release: IO[Nothing, Unit] = semaphore.release
+  def fromCats[F[+_, +_]: BIOPanic](semaphore: Semaphore[F[Throwable, ?]]): BIOSemaphore[F] =
+    new BIOSemaphore[F] {
+      override def acquire: F[Nothing, Unit] = semaphore.acquire.orTerminate
+      override def release: F[Nothing, Unit] = semaphore.release.orTerminate
 
-      override def acquireN(n: Long): IO[Nothing, Unit] = semaphore.acquireN(n)
-      override def releaseN(n: Long): IO[Nothing, Unit] = semaphore.releaseN(n)
+      override def acquireN(n: Long): F[Nothing, Unit] = semaphore.acquireN(n).orTerminate
+      override def releaseN(n: Long): F[Nothing, Unit] = semaphore.releaseN(n).orTerminate
     }
 }
diff --git a/fundamentals/fundamentals-bio/src/main/scala/izumi/functional/bio/impl/BIOZio.scala b/fundamentals/fundamentals-bio/src/main/scala/izumi/functional/bio/impl/BIOZio.scala
index d297e5222..b7425cbfc 100644
--- a/fundamentals/fundamentals-bio/src/main/scala/izumi/functional/bio/impl/BIOZio.scala
+++ b/fundamentals/fundamentals-bio/src/main/scala/izumi/functional/bio/impl/BIOZio.scala
@@ -1,15 +1,17 @@
 package izumi.functional.bio.impl
 
-import java.util.concurrent.{CompletionException, CompletionStage}
+import java.util.concurrent.CompletionStage
 
 import izumi.functional.bio.BIOExit.ZIOExit
-import izumi.functional.bio.{BIOAsync, BIOExit, BIOFiber, BIOTemporal}
+import izumi.functional.bio.{BIOAsync, BIOExit, BIOFiber, BIOTemporal, __PlatformSpecific}
+import zio.ZIO.ZIOWithFilterOps
 import zio.clock.Clock
+import zio.compatrc18.zio_succeed_Now.succeedNow
 import zio.duration.Duration.fromScala
-import zio.{Schedule, Task, ZIO}
+import zio.{Schedule, ZIO}
 
 import scala.concurrent.duration.{Duration, FiniteDuration}
-import scala.concurrent.{ExecutionContext, ExecutionException, Future}
+import scala.concurrent.{ExecutionContext, Future}
 import scala.util.Try
 
 object BIOZio extends BIOZio[Any]
@@ -17,13 +19,13 @@ object BIOZio extends BIOZio[Any]
 class BIOZio[R] extends BIOAsync[ZIO[R, +?, +?]] {
   private[this] final type IO[+E, +A] = ZIO[R, E, A]
 
-  @inline override final def pure[A](a: A): IO[Nothing, A] = ZIO.succeed(a)
+  @inline override final def pure[A](a: A): IO[Nothing, A] = succeedNow(a)
   @inline override final def sync[A](effect: => A): IO[Nothing, A] = ZIO.effectTotal(effect)
   @inline override final def syncThrowable[A](effect: => A): IO[Throwable, A] = ZIO.effect(effect)
   @inline override final def suspend[A](effect: => IO[Throwable, A]): IO[Throwable, A] = ZIO.effectSuspend(effect)
 
-  @inline override final def fail[E](v: => E): IO[E, Nothing] = ZIO.effectTotal(v).flatMap[R, E, Nothing](ZIO.fail)
-  @inline override final def terminate(v: => Throwable): IO[Nothing, Nothing] = ZIO.effectTotal(v).flatMap[R, Nothing, Nothing](ZIO.die)
+  @inline override final def fail[E](v: => E): IO[E, Nothing] = ZIO.fail(v)
+  @inline override final def terminate(v: => Throwable): IO[Nothing, Nothing] = ZIO.die(v)
 
   @inline override final def fromEither[L, R0](v: => Either[L, R0]): IO[L, R0] = ZIO.fromEither(v)
   @inline override final def fromTry[A](effect: => Try[A]): IO[Throwable, A] = ZIO.fromTry(effect)
@@ -44,21 +46,20 @@ class BIOZio[R] extends BIOAsync[ZIO[R, +?, +?]] {
   @inline override final def flatten[E, A](r: IO[E, IO[E, A]]): IO[E, A] = ZIO.flatten(r)
   @inline override final def *>[E, A, B](f: IO[E, A], next: => IO[E, B]): IO[E, B] = f *> next
   @inline override final def <*[E, A, B](f: IO[E, A], next: => IO[E, B]): IO[E, A] = f <* next
-  @inline override final def map2[E, A, B, C](r1: IO[E, A], r2: => IO[E, B])(f: (A, B) => C): IO[E, C] = {
-    r1.zipWith(ZIO.effectSuspendTotal(r2))(f)
-  }
+  @inline override final def map2[E, A, B, C](r1: IO[E, A], r2: => IO[E, B])(f: (A, B) => C): IO[E, C] = r1.zipWith(r2)(f)
 
   @inline override final def redeem[E, A, E2, B](r: IO[E, A])(err: E => IO[E2, B], succ: A => IO[E2, B]): IO[E2, B] = r.foldM(err, succ)
   @inline override final def catchAll[E, A, E2, A2 >: A](r: IO[E, A])(f: E => IO[E2, A2]): IO[E2, A2] = r.catchAll(f)
   @inline override final def catchSome[E, A, E2 >: E, A2 >: A](r: ZIO[R, E, A])(f: PartialFunction[E, ZIO[R, E2, A2]]): ZIO[R, E2, A2] = r.catchSome(f)
-  @inline override final def withFilter[E, A](r: IO[E, A])(predicate: A => Boolean)(implicit ev: NoSuchElementException <:< E): IO[E, A] = r.withFilter(predicate)
+  @inline override final def withFilter[E, A](r: IO[E, A])(predicate: A => Boolean)(implicit ev: NoSuchElementException <:< E): IO[E, A] =
+    new ZIOWithFilterOps(r).withFilter(predicate)(ev)
 
   @inline override final def guarantee[E, A](f: IO[E, A])(cleanup: IO[Nothing, Unit]): IO[E, A] = f.ensuring(cleanup)
   @inline override final def attempt[E, A](r: IO[E, A]): IO[Nothing, Either[E, A]] = r.either
   @inline override final def redeemPure[E, A, B](r: IO[E, A])(err: E => B, succ: A => B): IO[Nothing, B] = r.fold(err, succ)
 
   @inline override final def bracket[E, A, B](acquire: IO[E, A])(release: A => IO[Nothing, Unit])(use: A => IO[E, B]): IO[E, B] = {
-    ZIO.bracket(acquire)(v => release(v))(use)
+    ZIO.bracket(acquire)(release)(use)
   }
 
   @inline override final def bracketCase[E, A, B](acquire: IO[E, A])(release: (A, BIOExit[E, B]) => IO[Nothing, Unit])(use: A => IO[E, B]): IO[E, B] = {
@@ -77,29 +78,27 @@ class BIOZio[R] extends BIOAsync[ZIO[R, +?, +?]] {
   @inline override final def yieldNow: IO[Nothing, Unit] = ZIO.yieldNow
   @inline override final def never: IO[Nothing, Nothing] = ZIO.never
 
-  @inline override final def race[E, A](r1: IO[E, A], r2: IO[E, A]): IO[E, A] = {
-    r1.raceAttempt(r2)
-  }
+  @inline override final def race[E, A](r1: IO[E, A], r2: IO[E, A]): IO[E, A] = r1.raceFirst(r2)
 
   @inline override final def racePair[E, A, B](r1: IO[E, A], r2: IO[E, B]): IO[E, Either[(A, BIOFiber[ZIO[R, +?, +?], E, B]), (BIOFiber[ZIO[R, +?, +?], E, A], B)]] = {
     (r1 raceWith r2)(
-      { case (l, f) => l.fold(f.interrupt *> ZIO.halt(_), ZIO.succeed).map(lv => Left((lv, BIOFiber.fromZIO(f)))) },
-      { case (r, f) => r.fold(f.interrupt *> ZIO.halt(_), ZIO.succeed).map(rv => Right((BIOFiber.fromZIO(f), rv))) }
+      { case (l, f) => l.fold(f.interrupt *> ZIO.halt(_), succeedNow).map(lv => Left((lv, BIOFiber.fromZIO(f)))) },
+      { case (r, f) => r.fold(f.interrupt *> ZIO.halt(_), succeedNow).map(rv => Right((BIOFiber.fromZIO(f), rv))) }
     )
   }
 
   @inline override final def async[E, A](register: (Either[E, A] => Unit) => Unit): IO[E, A] = {
-    ZIO.effectAsync(cb => register(cb apply _.fold(ZIO.fail, ZIO.succeed)))
+    ZIO.effectAsync(cb => register(cb apply _.fold(ZIO.fail(_), succeedNow)))
   }
 
   @inline override final def asyncF[E, A](register: (Either[E, A] => Unit) => ZIO[R, E, Unit]): ZIO[R, E, A] = {
-    ZIO.effectAsyncM(cb => register(cb apply _.fold(ZIO.fail, ZIO.succeed)))
+    ZIO.effectAsyncM(cb => register(cb apply _.fold(ZIO.fail(_), succeedNow)))
   }
 
   @inline override final def asyncCancelable[E, A](register: (Either[E, A] => Unit) => Canceler): IO[E, A] = {
     ZIO.effectAsyncInterrupt[R, E, A] {
       cb =>
-        val canceler = register(cb apply _.fold(ZIO.fail, ZIO.succeed))
+        val canceler = register(cb apply _.fold(ZIO.fail(_), succeedNow))
         Left(canceler)
     }
   }
@@ -109,37 +108,7 @@ class BIOZio[R] extends BIOAsync[ZIO[R, +?, +?]] {
   }
 
   @inline override final def fromFutureJava[A](javaFuture: => CompletionStage[A]): IO[Throwable, A] = {
-    def unwrapDone[T](isFatal: Throwable => Boolean)(f: java.util.concurrent.Future[T]): Task[T] = {
-      try Task.succeed(f.get()) catch catchFromGet(isFatal)
-    }
-    def catchFromGet(isFatal: Throwable => Boolean): PartialFunction[Throwable, Task[Nothing]] = {
-      case e: CompletionException =>
-        Task.fail(e.getCause)
-      case e: ExecutionException =>
-        Task.fail(e.getCause)
-      case _: InterruptedException =>
-        Task.interrupt
-      case e if !isFatal(e) =>
-        Task.fail(e)
-    }
-    ZIO.effect(javaFuture).flatMap[R, Throwable, A](javaFuture => Task.effectSuspendTotalWith { p =>
-      val cf = javaFuture.toCompletableFuture
-      if (cf.isDone) {
-        unwrapDone(p.fatal)(cf)
-      } else {
-        Task.effectAsync {
-          cb =>
-            val _ = javaFuture.handle[Unit] {
-              (v: A, t: Throwable) =>
-                val io = Option(t).fold[Task[A]](Task.succeed(v)) {
-                  t =>
-                    catchFromGet(p.fatal).lift(t).getOrElse(Task.die(t))
-                }
-                cb(io)
-            }
-        }
-      }
-    })
+    __PlatformSpecific.fromFutureJava(javaFuture)
   }
 
   @inline override final def uninterruptible[E, A](r: IO[E, A]): IO[E, A] = r.uninterruptible
@@ -150,10 +119,9 @@ class BIOZio[R] extends BIOAsync[ZIO[R, +?, +?]] {
   @inline override final def parTraverse_[E, A, B](l: Iterable[A])(f: A => ZIO[R, E, B]): ZIO[R, E, Unit] = ZIO.foreachPar_(l)(f)
 }
 
-class BIOTemporalZio[R](private val clockService: Clock) extends BIOZio[R] with BIOTemporal[ZIO[R, +?, +?]] {
-
+class BIOTemporalZio[R](private val clock: Clock) extends BIOZio[R] with BIOTemporal[ZIO[R, +?, +?]] {
   @inline override final def sleep(duration: Duration): ZIO[R, Nothing, Unit] = {
-    ZIO.sleep(fromScala(duration)).provide(clockService)
+    ZIO.sleep(fromScala(duration)).provide(clock)
   }
 
   @inline override final def retryOrElse[A, E, A2 >: A, E2](r: ZIO[R, E, A])(duration: FiniteDuration, orElse: => ZIO[R, E2, A2]): ZIO[R, E2, A2] =
@@ -162,11 +130,11 @@ class BIOTemporalZio[R](private val clockService: Clock) extends BIOZio[R] with
 
       r.provide(env)
         .retryOrElse(zioDuration, (_: Any, _: Any) => orElse.provide(env))
-        .provide(clockService)
+        .provide(clock)
     }
 
   @inline override final def timeout[E, A](r: ZIO[R, E, A])(duration: Duration): ZIO[R, E, Option[A]] = {
-    ZIO.accessM[R](r.provide(_).timeout(fromScala(duration)).provide(clockService))
+    ZIO.accessM[R](r.provide(_).timeout(fromScala(duration)).provide(clock))
   }
 
 }
diff --git a/fundamentals/fundamentals-bio/src/main/scala/izumi/functional/bio/package.scala b/fundamentals/fundamentals-bio/src/main/scala/izumi/functional/bio/package.scala
index 764752f01..3b7fa1973 100644
--- a/fundamentals/fundamentals-bio/src/main/scala/izumi/functional/bio/package.scala
+++ b/fundamentals/fundamentals-bio/src/main/scala/izumi/functional/bio/package.scala
@@ -286,9 +286,7 @@ package object bio extends BIOSyntax {
           //  unless wrapped in `interruptible`
           //  see: https://github.com/zio/zio/issues/945
           .interruptible
-          .nonDaemon
-          .fork
-          .daemon
+          .forkDaemon
           .map(BIOFiber.fromZIO)
     }
   }
diff --git a/fundamentals/fundamentals-bio/src/main/scala/zio/clock/compatrc18/zio_Clock_Live.scala b/fundamentals/fundamentals-bio/src/main/scala/zio/clock/compatrc18/zio_Clock_Live.scala
new file mode 100644
index 000000000..a30ed4b62
--- /dev/null
+++ b/fundamentals/fundamentals-bio/src/main/scala/zio/clock/compatrc18/zio_Clock_Live.scala
@@ -0,0 +1,32 @@
+package zio.clock.compatrc18
+
+import java.time.{Instant, OffsetDateTime, ZoneId}
+import java.util.concurrent.TimeUnit
+
+import zio.clock.Clock
+import zio.duration.Duration
+import zio.{Has, IO, UIO, ZIO}
+
+// workaround for missing static Clock.Live
+object zio_Clock_Live extends Clock.Service {
+  def currentTime(unit: TimeUnit): UIO[Long] = {
+    IO.effectTotal(System.currentTimeMillis).map(l => unit.convert(l, TimeUnit.MILLISECONDS))
+  }
+  val nanoTime: UIO[Long] = IO.effectTotal(System.nanoTime)
+
+  def sleep(duration: Duration): UIO[Unit] = {
+    UIO.effectAsyncInterrupt {
+      cb =>
+        val canceler = zio.clock.Clock.globalScheduler.schedule(() => cb(UIO.unit), duration)
+        Left(UIO.effectTotal(canceler()))
+    }
+  }
+  def currentDateTime: ZIO[Any, Nothing, OffsetDateTime] = {
+    for {
+      millis <- currentTime(TimeUnit.MILLISECONDS)
+      zone <- ZIO.effectTotal(ZoneId.systemDefault)
+    } yield OffsetDateTime.ofInstant(Instant.ofEpochMilli(millis), zone)
+  }
+
+  val live: Has[Clock.Service] = Has(this)
+}
diff --git a/fundamentals/fundamentals-bio/src/main/scala/zio/compatrc18/zio_succeed_Now.scala b/fundamentals/fundamentals-bio/src/main/scala/zio/compatrc18/zio_succeed_Now.scala
new file mode 100644
index 000000000..e15a83b85
--- /dev/null
+++ b/fundamentals/fundamentals-bio/src/main/scala/zio/compatrc18/zio_succeed_Now.scala
@@ -0,0 +1,5 @@
+package zio.compatrc18
+
+object zio_succeed_Now {
+  @inline def succeedNow[A](a: A): zio.ZIO[Any, Nothing, A] = new zio.ZIO.Succeed[A](a)
+}
diff --git a/project/Versions.scala b/project/Versions.scala
index bd791160c..f40f6bf0b 100644
--- a/project/Versions.scala
+++ b/project/Versions.scala
@@ -9,8 +9,8 @@ object V {
 
   val cats = "2.1.1"
   val cats_effect = "2.1.2"
-  val zio = "1.0.0-RC17"
-  val zio_interop_cats = "2.0.0.0-RC10"
+  val zio = "1.0.0-RC18-1"
+  val zio_interop_cats = "2.0.0.0-RC11"
 
   val circe = "0.13.0"
   val circe_generic_extras = "0.13.0"


Test patch:
diff --git a/fundamentals/fundamentals-bio/.jvm/src/test/scala/izumi/functional/bio/test/BlockingIOSyntaxTest.scala b/fundamentals/fundamentals-bio/.jvm/src/test/scala/izumi/functional/bio/test/BlockingIOSyntaxTest.scala
index 8555f4cf5..d26d38892 100644
--- a/fundamentals/fundamentals-bio/.jvm/src/test/scala/izumi/functional/bio/test/BlockingIOSyntaxTest.scala
+++ b/fundamentals/fundamentals-bio/.jvm/src/test/scala/izumi/functional/bio/test/BlockingIOSyntaxTest.scala
@@ -15,7 +15,7 @@ class BlockingIOSyntaxTest extends AnyWordSpec {
     F.syncBlocking(2)
   }
   val _: ZIO[Blocking, Throwable, Int] = {
-    implicit val b: zio.blocking.Blocking = zio.blocking.Blocking.Live
+    implicit val blocking: Blocking = zio.Runtime.unsafeFromLayer(Blocking.live).environment
     `attach BlockingIO methods to a trifunctor BIO`[BlockingIOInstances.ZIOBlocking#l]
     `attach BlockingIO methods to a bifunctor BIO`[zio.IO]
   }
@@ -30,7 +30,7 @@ class BlockingIOSyntaxTest extends AnyWordSpec {
 
     assert(new X[zio.ZIO[Blocking, +?, +?]].hello != null)
     locally {
-      implicit val blocking: Blocking.Live.type = zio.blocking.Blocking.Live
+      implicit val blocking: Blocking = zio.Runtime.unsafeFromLayer(Blocking.live).environment
       assert(new X[zio.IO].hello != null)
     }
     assert(new X3[BlockingIOInstances.ZIOBlocking#l].hello != null)