Last active
December 30, 2015 19:59
-
-
Save klaeufer/7877992 to your computer and use it in GitHub Desktop.
minimal scalaz monoid example
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
| import scalaz._ // general scalaz support | |
| import syntax.monoid._ // monoid syntax as used below | |
| import std.anyVal._ // some instances to work with | |
| import std.list._ // some more instances | |
| import std.option._ // some more instances | |
| import syntax.std.option._ // postfix methods for options | |
| object monoidExample { | |
| val res0 = ∅[Int] // or: mzero[Int] | |
| val res1 = 3 |+| 4 // or: 3 `mappend` 4 | |
| val res2 = ∅[List[Int]] | |
| val res3 = List(1, 2, 3) |+| List(4, 5) | |
| val res4 = none[Option[Int]] | |
| val res5 = 3.some |+| 4.some | |
| val res6 = 3.some |+| none | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment