Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save deanwampler/c0cb301d7cbd6aafba3f99925d6e859f to your computer and use it in GitHub Desktop.
Save deanwampler/c0cb301d7cbd6aafba3f99925d6e859f to your computer and use it in GitHub Desktop.
given StringMonoid: Monoid[String] with
def unit: String = ""
extension (s: String) def combine(other: String): String = s + other
"2" <+> ("3" <+> "4") // "234"
("2" <+> "3") <+> "4" // "234"
StringMonoid.unit <+> "2" // "2"
"2" <+> StringMonoid.unit // "2"
"2" `combine` ("3" `combine` "4")
("2" `combine` "3") `combine` "4"
StringMonoid.unit `combine` "2"
"2" `combine` StringMonoid.unit
"2" combine {"3" combine {"4"}}
"2" combine {"3"} combine {"4"}
StringMonoid.unit combine {"2"}
"2" combine {StringMonoid.unit}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment