Last active
December 22, 2015 00:39
-
-
Save uris77/6390937 to your computer and use it in GitHub Desktop.
Monoid for trimming strings.
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
def trimMonoid(s: String): Monoid[String] = new Monoid[String] { | |
def op(x: String, y: String) = x.trim() + " " + y.trim() | |
val zero = "" | |
} | |
trimMonoid("").op("Something ", " Somewhere ") //=> Something Somewhere |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment