Skip to content

Instantly share code, notes, and snippets.

@andyscott
Created September 1, 2016 19:21
Show Gist options
  • Save andyscott/e8dac2a29186d24bd4649e592111db91 to your computer and use it in GitHub Desktop.
Save andyscott/e8dac2a29186d24bd4649e592111db91 to your computer and use it in GitHub Desktop.
// toying with some abstractions with akka
trait Pipeable[F[_]] {
def pipe(value: F[_], target: ActorRef)(implicit sender: ActorRef = ActorRef.noSender): Unit
}
object Pipeable extends PipeableImplicits {
def apply[F[_]](implicit ev: Pipeable[F]): Pipeable[F] = ev
}
sealed trait PipeableImplicits {
implicit val pipeableFuture: Pipeable[Future] =
new Pipeable[Future] {
def pipe(value: Future[_], target: ActorRef)(implicit sender: ActorRef) {
akka.pattern.pipe(value).to(target, sender)
}
}
implicit val pipeableId: Pipeable[Id] =
new Pipeable[Id] {
def pipe(value: Id[_], target: ActorRef)(implicit sender: ActorRef) {
target.tell(value, sender)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment