Created
December 4, 2011 21:51
-
-
Save halcat0x15a/1431400 to your computer and use it in GitHub Desktop.
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
| scala> (nil[Int]: MA[List, Int]) | |
| res65: scalaz.MA[List,Int] = scalaz.MAs$$anon$3@1d45221 | |
| scala> (none[String]: MA[Option, String]) | |
| res66: scalaz.MA[Option,String] = scalaz.MAsLow$$anon$1@90cae4 | |
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
| 1 ?|? 1 assert_=== EQ | |
| 1 ?|? 2 assert_=== LT | |
| 2 ?|? 1 assert_=== GT | |
| "Scalaz" ?|? "Scala" assert_=== GT | |
| List(2, 4) ?|? List(3, 5) assert_=== LT |
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
| assert(1 lt 2) | |
| assert(2 gt 1) | |
| assert("Scalaz" gt "Scala") | |
| assert(List(2, 4) lt List(3, 5)) |
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
| 1 max 1 assert_=== 1 | |
| 1 max 2 assert_=== 2 | |
| 2 min 1 assert_=== 1 | |
| Identity("Scala") max "Scalaz" assert_=== "Scalaz" | |
| Identity(List(2, 4)) min List(3, 5) assert_=== List(2, 4) |
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
| case class Ikamusume(syokusyu: Int) | |
| implicit def IkamusumeOrder: Order[Ikamusume] = order(_.syokusyu ?|? _.syokusyu) | |
| implicit def IkamusumeOrder: Order[Ikamusume] = orderBy(_.syokusyu) | |
| Ikamusume(10) ?|? Ikamusume(100) assert_=== LT |
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
| (1 ?|? 1) |+| (1 ?|? 1) |+| (1 ?|? 1) assert_=== EQ | |
| (1 ?|? 1) |+| (1 ?|? 2) |+| (2 ?|? 1) assert_=== LT | |
| (1 ?|? 1) |+| (2 ?|? 1) |+| (1 ?|? 2) assert_=== GT |
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
| case class ScalaChan[A](value: A) | |
| implicit def ScalaChanEqual[A]: Equal[ScalaChan[A]] = equalA | |
| implicit def ScalaChanShow[A]: Show[ScalaChan[A]] = showA | |
| implicit def ScalaChanPure = new Pure[ScalaChan] { | |
| def pure[A](a: => A) = ScalaChan(a) | |
| } | |
| "Scalaちゃん".pure[ScalaChan] assert_=== ScalaChan("Scalaちゃん") |
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
| 1.pure[List] assert_=== List(1) | |
| "Scalaz".pure[Option] assert_=== "Scalaz".some | |
| 'Scalaz.pure[Function0] assert_=== (() => 'Scalaz) |
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
| 1.iterate[Stream](1 +).take(3) assert_=== Stream(1, 2, 3) | |
| 1.repeat[Stream].take(3) assert_=== Stream(1, 1, 1) | |
| 1.replicate[List](3) assert_=== List(1, 1, 1) | |
| lazy val nextPrime: Int => Int = _.doWhile(1 +, i => (2 until i).any(i % _ == 0)) | |
| 2.iterate[Stream](nextPrime).take(5) assert_=== Stream(2, 3, 5, 7, 11) | |
| 2.replicate[List](5, nextPrime) assert_=== List(2, 3, 5, 7, 11) | |
| 2.replicate[Option](3) assert_=== 6.some |
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
| 1 +>: List(1) assert_=== List(1, 1) | |
| 1 +>: 1.some assert_=== 2.some | |
| (1 +>: ((_: Int) + 1)).apply(1) assert_=== 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment