Skip to content

Instantly share code, notes, and snippets.

@halcat0x15a
Created December 22, 2011 14:46
Show Gist options
  • Save halcat0x15a/1510534 to your computer and use it in GitHub Desktop.
Save halcat0x15a/1510534 to your computer and use it in GitHub Desktop.
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]
implicit lazy val m = IntProductReducer
implicit lazy val l = ListReducer[Int]
1.unit[IntMultiplication] assert_=== (1 ∏)
1.unit[List[Int]] assert_=== List(1)
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)
1.pureUnit[List, IntMultiplication] assert_=== List(1 ∏)
100.pureUnit[Option, List[Int]] assert_=== Some(List(100))
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