Skip to content

Instantly share code, notes, and snippets.

@nlim
Created January 8, 2016 20:29
Show Gist options
  • Save nlim/02380949314f4bab2322 to your computer and use it in GitHub Desktop.
Save nlim/02380949314f4bab2322 to your computer and use it in GitHub Desktop.
Future to Task
def toTask[T](ft: => Future[T]): Task[T] = {
import scalaz._
import scalaz.Scalaz._
Task.async { register =>
ft.onComplete({
case scala.util.Success(v) => register(\/-(v))
case scala.util.Failure(ex) => register(-\/(ex))
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment