Skip to content

Instantly share code, notes, and snippets.

@Tvaroh
Created September 25, 2018 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Tvaroh/207ba3b287e12d33b113df1a0583eab8 to your computer and use it in GitHub Desktop.
Save Tvaroh/207ba3b287e12d33b113df1a0583eab8 to your computer and use it in GitHub Desktop.
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