Created
December 22, 2011 14:46
-
-
Save halcat0x15a/1510534 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
Generator.FoldrGenerator[List].from(StreamReducer[String], List("Scala", "Scalaz"), Stream.empty) assert_=== Stream("Scala", "Scalaz") | |
Generator.FoldlGenerator[List].to(FirstReducer[String], mzero[FirstOption[String]], List("Scala", "Scalaz")) assert_=== "Scala".pure[FirstOption] | |
Generator.FoldMapGenerator[List].reduce(LastReducer[String], List("Scala", "Scalaz")) assert_=== "Scalaz".pure[LastOption] |
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
implicit lazy val m = IntProductReducer | |
implicit lazy val l = ListReducer[Int] | |
1.unit[IntMultiplication] assert_=== (1 ∏) | |
1.unit[List[Int]] assert_=== List(1) |
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
5.cons(2 ∏) assert_=== (10 ∏) | |
(3 ∏).snoc(4) assert_=== (12 ∏) | |
5.cons(nil[Int]) assert_=== List(5) | |
List(1).snoc(1) assert_=== List(1, 1) |
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
1.pureUnit[List, IntMultiplication] assert_=== List(1 ∏) | |
100.pureUnit[Option, List[Int]] assert_=== Some(List(100)) |
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
List(1, 2, 3, 4).foldReduce[IntMultiplication] assert_=== (24 ∏) | |
nel(1, 2, 3, 4).foldReduce[List[Int]] assert_=== List(1, 2, 3, 4) | |
implicit lazy val s = DualReducer[String] | |
nel("Hello", "World").foldReduce[Dual[String]].value assert_=== "WorldHello" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment