Skip to content

Instantly share code, notes, and snippets.

@fiadliel
Created December 17, 2014 17:23
Show Gist options
  • Save fiadliel/8601991413b0654fdd16 to your computer and use it in GitHub Desktop.
Save fiadliel/8601991413b0654fdd16 to your computer and use it in GitHub Desktop.
implicit class Task2FutureWrapper[A](task: scalaz.concurrent.Task[A]) {
import scala.concurrent.{Future, Promise}
import scalaz.{-\/,\/-}
def runFuture(): Future[A] = {
val p = Promise[A]()
task.runAsync {
case -\/(t) => p.failure(t)
case \/-(r) => p.success(r)
}
p.future
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment