Skip to content

Commit

Permalink
Add ZIO for running effects.
Browse files Browse the repository at this point in the history
  • Loading branch information
khajavi committed Jan 11, 2020
1 parent d037419 commit fb1e544
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
2 changes: 2 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ libraryDependencies ++= Seq(

libraryDependencies += "io.monix" %% "monix" % "3.1.0"
libraryDependencies += "io.monix" %% "monix-eval" % "3.1.0"
libraryDependencies += "dev.zio" %% "zio-interop-cats" % "2.0.0.0-RC10"

22 changes: 15 additions & 7 deletions src/main/scala/com/speakfreely/tasbih/Main.scala
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
package com.speakfreely.tasbih

import java.io.IOException
import java.util.Date

import cats.effect.{ExitCode, Sync}
import cats.effect.Sync
import cats.implicits._
import monix.eval.{Task, TaskApp}
import tsec.common._
import tsec.hashing.jca._
import zio.ZIO
import zio.console._
import zio.interop.catz._

import scala.language.higherKinds
import scala.util.{Failure, Success, Try}

object Main extends TaskApp {
override def run(args: List[String]): Task[ExitCode] = {
val b = BlockChain[Task]
object Main extends CatsApp {

override def run(args: List[String]): ZIO[Console, Nothing, Int] =
myAppLogic.fold(_ => 1, _ => 0)

type TaskA[+A] = ZIO[Any, Throwable, A]
val myAppLogic: ZIO[Any, Throwable, Unit] = {
val b: BlockChain[TaskA] = BlockChain[TaskA]
for {
b1 <- b.addBlock("Hello")
b2 <- b1.addBlock("Block")
b3 <- b2.addBlock("Chain!")
_ <- Task(println(b3))
} yield ExitCode.Success
_ <- ZIO.apply(println(b3))
} yield ()
}
}

Expand Down

0 comments on commit fb1e544

Please sign in to comment.