Skip to content

Instantly share code, notes, and snippets.

@uris77
Last active December 22, 2015 00:39
Show Gist options
  • Save uris77/6390937 to your computer and use it in GitHub Desktop.
Save uris77/6390937 to your computer and use it in GitHub Desktop.
Monoid for trimming strings.
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