Last active
March 28, 2021 16:10
-
-
Save deanwampler/c0cb301d7cbd6aafba3f99925d6e859f 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
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