forked from zio/interop-cats
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ZIO/RIO/IO/Task.concurrentEffect & concurrentEffectWith helpers (z…
…io#111) * Add ZIO/RIO/IO/Task.concurrentEffect & concurrentEffectWith helpers * silence unused warnings via deprecated annotation
- Loading branch information
Showing
4 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
interop-cats/shared/src/main/scala/zio/interop/CatsConcurrentEffectSyntax.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package zio.interop | ||
|
||
import cats.effect.ConcurrentEffect | ||
import zio.{ IO, RIO, Runtime, Task, ZIO } | ||
|
||
import scala.language.implicitConversions | ||
|
||
trait CatsConcurrentEffectSyntax { | ||
implicit final def ZIOConcurrentEffectOps(@deprecated("", "") zio: ZIO.type): CatsConcurrentEffectSyntax.zioOps.type = | ||
CatsConcurrentEffectSyntax.zioOps | ||
implicit final def RIOConcurrentEffectOps(@deprecated("", "") rio: RIO.type): CatsConcurrentEffectSyntax.zioOps.type = | ||
CatsConcurrentEffectSyntax.zioOps | ||
|
||
implicit final def IOConcurrentEffectOps(@deprecated("", "") io: IO.type): CatsConcurrentEffectSyntax.ioOps.type = | ||
CatsConcurrentEffectSyntax.ioOps | ||
implicit final def TaskConcurrentEffectOps(@deprecated("", "") io: Task.type): CatsConcurrentEffectSyntax.ioOps.type = | ||
CatsConcurrentEffectSyntax.ioOps | ||
} | ||
|
||
private[interop] object CatsConcurrentEffectSyntax { | ||
object zioOps { | ||
final def concurrentEffect[R]: ZIO[R, Nothing, ConcurrentEffect[RIO[R, *]]] = | ||
ZIO.runtime.map(catz.taskEffectInstance(_: Runtime[R])) | ||
final def concurrentEffectWith[R, E, A](f: ConcurrentEffect[RIO[R, *]] => ZIO[R, E, A]): ZIO[R, E, A] = | ||
ZIO.runtime.flatMap(f apply catz.taskEffectInstance(_: Runtime[R])) | ||
} | ||
object ioOps { | ||
final def concurrentEffect: ZIO[Any, Nothing, ConcurrentEffect[RIO[Any, *]]] = | ||
ZIO.runtime.map(catz.taskEffectInstance(_: Runtime[Any])) | ||
def concurrentEffectWith[E, A](f: ConcurrentEffect[RIO[Any, *]] => ZIO[Any, E, A]): ZIO[Any, E, A] = | ||
ZIO.runtime.flatMap(f apply catz.taskEffectInstance(_: Runtime[Any])) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters