scalaz-task-effect Build Status Maven Central

Please Consider Using Shims, as its necessary to not get conflicting instances.

Cats Effect Instances for Scalaz Concurrent Task. Trying to allow everything to play nicely together with minimal hardships.

Quick Start

To use scalaz-task-effect in an existing SBT project with Scala 2.11 or a later version, add the following dependency to your build.sbt:

libraryDependencies += "io.chrisdavenport" %% "scalaz-task-effect" % "<version>"

Getting Started

Get some imports out of the way.

import cats.implicits._
import cats.effect._
import scalaz.concurrent.Task

And then…

scala> // This gets the instances
     | import io.chrisdavenport.scalaz.task._
import io.chrisdavenport.scalaz.task._

scala> val usingCatsSyntax = Task.delay(println("Hello There!")) *> Task.delay(println("Very Convincing"))
usingCatsSyntax: scalaz.concurrent.Task[Unit] = scalaz.concurrent.Task@73232100

scala> usingCatsSyntax.unsafePerformSync
Hello There!
Very Convincing

scala> val summonImplicits = Sync[Task].delay(println("I came out to play!"))
summonImplicits: scalaz.concurrent.Task[Unit] = scalaz.concurrent.Task@4a008260

scala> summonImplicits.unsafePerformSync
I came out to play!

scala> val lifted = LiftIO[Task].liftIO(IO(println("I could have done arbitrary IO")))
lifted: scalaz.concurrent.Task[Unit] = scalaz.concurrent.Task@3081a5ec

scala> lifted.unsafePerformSync
I could have done arbitrary IO

scala> // A parametric function that you might find somewhere.
     | // Without an effect instance for Task,
     | // you couldn't use this function in a codebase operating in Task.
     | def putStrLn[F[_]: Sync](str: String): F[Unit] = Sync[F].delay(println(str))
putStrLn: [F[_]](str: String)(implicit evidence$1: cats.effect.Sync[F])F[Unit]

scala> // Using The Parametric Function
     | putStrLn[Task]("Parametric String Output Here!").unsafePerformSync
Parametric String Output Here!