takayahilton / eff-zio   1.0.0

MIT License GitHub

eff zio extension

Scala versions: 2.13 2.12 2.11
Scala.js versions: 0.6

eff-zio

Build Status Maven Central

This library is eff extension for ZIO effects.

Installation

// check maven badge above for latest version
libraryDependencies += "com.github.takayahilton" %% "eff-zio" % "1.0.0"

// to write types like Reader[String, *]
addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.13.0")

// to get types like Reader[String, *] (with more than one type parameter) correctly inferred for scala 2.12.x
scalacOptions += "-Ypartial-unification"

Usage

import com.github.takayahilton.eff.zio._
import org.atnos.eff._
import org.atnos.eff.all._
import org.atnos.eff.syntax.all._
import zio.{Runtime, UIO}

val runtime = Runtime.default

type S1 = Fx.fx2[UIO, Option]

def action[R: _uio: _option]: Eff[R, Int] =
  for {
    a <- succeedLazy(10)
    b <- succeedLazy(20)
  } yield a + b

val zio = action[S1].runOption.runAsync

runtime.unsafeRun(zio) // Some(30)