Created
September 25, 2018 16:21
-
-
Save Tvaroh/207ba3b287e12d33b113df1a0583eab8 to your computer and use it in GitHub Desktop.
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
import scala.concurrent.Future | |
/** Typeclass for interoperating with legacy code which uses Scala futures. */ | |
trait ExecuteUnsafe[F[_]] { | |
def unsafeToFuture[T](mt: F[T]): Future[T] | |
} | |
object ExecuteUnsafe { | |
def apply[F[_]: ExecuteUnsafe]: ExecuteUnsafe[F] = | |
implicitly[ExecuteUnsafe[F]] | |
implicit val future: ExecuteUnsafe[Future] = FutureExecuteUnsafe | |
private object FutureExecuteUnsafe extends ExecuteUnsafe[Future] { | |
override def unsafeToFuture[T](future: Future[T]): Future[T] = future | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment