Last active
January 26, 2017 10:50
-
-
Save kubukoz/c42d9a3a09aaeec10256bba4094a2cc2 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 | |
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) | |
} | |
//sample | |
import scalaz.std.scalaFuture._ | |
import scalaz.std.option._ | |
import scala.concurrent.ExecutionContext.Implicits.global | |
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