Skip to content

Instantly share code, notes, and snippets.

Last active January 26, 2017 10:50
What would you like to do?
import scala.concurrent.Future
import scala.language.higherKinds
import scalaz.Functor
* Created by kubukoz on 25/01/2017.
object ComposedFunctors {
implicit class ComposedMapOps[F[_], G[_], T](val functor: F[G[T]]) extends AnyVal {
def cmap[U](f: T => U)(implicit G: Functor[G], F: Functor[F]): F[G[U]] = (F compose G).map(functor)(f)
import scalaz.std.scalaFuture._
import scalaz.std.option._
val x: Future[Option[Int]] = Future(Option(5)).cmap(_ + 5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment