Skip to content

Instantly share code, notes, and snippets.

@sshark
Forked from jto/kleisli.scala
Last active June 5, 2016 14:58
Show Gist options
  • Save sshark/70928b8fdc50aa17b099a0849d07b355 to your computer and use it in GitHub Desktop.
Save sshark/70928b8fdc50aa17b099a0849d07b355 to your computer and use it in GitHub Desktop.
For future reference on Kleisli
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