Created
February 17, 2014 08:25
-
-
Save xuwei-k/9046815 to your computer and use it in GitHub Desktop.
This file contains 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
libraryDependencies += "org.scalaz" %% "scalaz-core" % "7.1.0-M5" |
This file contains 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
object Main1 { | |
val f = (_: List[Int]).headOption | |
val g = (_: Int) + 1 | |
val h = (_: Int) + 2 | |
val x: Int => Option[Int] = ??? | |
val y: Int => Option[Int] = ??? | |
def main(args: Array[String]){ | |
val i = f.andThen(_.map(g).map(h)) | |
val z = f.andThen(_.flatMap(x).flatMap(y)) | |
println(i(List(3, 5))) | |
} | |
} | |
object Main2 { | |
import Main1._ | |
import scalaz._, std.option._ | |
def main(args: Array[String]){ | |
val i = Kleisli(f).map(g).map(h) | |
val z = Kleisli(f) >==> x >==> y | |
println(i(List(3, 5))) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment