-
-
Save sshark/70928b8fdc50aa17b099a0849d07b355 to your computer and use it in GitHub Desktop.
For future reference on Kleisli
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 scalaz._ | |
import Scalaz._ | |
import scala.concurrent.Future | |
import scalaz.std.scalaFuture._ | |
import play.api.libs.concurrent.Execution.Implicits._ | |
val f1 = (s: String) => Option("foo").point[Future] | |
def f2 = (s: String) => Option(1).point[Future] | |
type OptionTFuture[T] = OptionT[Future, T] | |
for { | |
e1 <- Kleisli(f1).mapK[OptionTFuture, String](OptionT.apply _) | |
e2 <- Kleisli(f2).mapK[OptionTFuture, Int](OptionT.apply _) | |
} yield e1 + e2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment