Created
January 8, 2016 20:29
-
-
Save nlim/02380949314f4bab2322 to your computer and use it in GitHub Desktop.
Future to Task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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