Skip to content

Commit

Permalink
Add instances for fs2.io (#668)
Browse files Browse the repository at this point in the history
  • Loading branch information
grouzen authored May 24, 2023
1 parent f9f65de commit c46cc09
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ lazy val zioInteropCats = crossProject(JSPlatform, JVMPlatform)
"dev.zio" %%% "zio-stacktracer" % zioVersion,
"org.typelevel" %%% "cats-effect-std" % catsEffectVersion,
"org.typelevel" %%% "cats-mtl" % catsMtlVersion,
"co.fs2" %%% "fs2-core" % fs2Version
"co.fs2" %%% "fs2-core" % fs2Version,
"co.fs2" %%% "fs2-io" % fs2Version
)
val optLibraries = if (scalaVersion.value.startsWith("3")) optLibraries0 else optLibraries0.map(_ % Optional)
("dev.zio" %%% "zio" % zioVersion) :: optLibraries
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
package zio.stream.interop

object fs2z extends FS2Platform
import fs2.io.net.Network
import fs2.io.file.Files
import fs2.io.net.unixsocket.UnixSockets
import zio.*
import zio.interop.CatsEffectInstances

object fs2z extends FS2Platform {
object io extends FS2IOPlatform
}

abstract class FS2Platform extends FS2StreamSyntax

abstract class FS2IOPlatform extends FS2IOFilesInstances with FS2IONetworkInstances with FS2IOUnixSocketsInstances

trait FS2IOFilesInstances extends CatsEffectInstances {

implicit final def filesInstance[R]: Files[RIO[R, _]] =
Files.forAsync(asyncInstance[R])

}

trait FS2IONetworkInstances extends CatsEffectInstances {

implicit final def networkInstance[R]: Network[RIO[R, _]] =
Network.forAsync(asyncInstance[R])

}

trait FS2IOUnixSocketsInstances extends CatsEffectInstances {

implicit final def unixSocketsInstance[R]: UnixSockets[RIO[R, _]] =
UnixSockets.forAsync(asyncInstance[R])

}

0 comments on commit c46cc09

Please sign in to comment.