Last active
December 27, 2020 15:39
-
-
Save deanwampler/bf09427538c38041c65ba028e935312f to your computer and use it in GitHub Desktop.
This file contains 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 NumericMonoid[T](using num: Numeric[T]): Monoid[T] with | |
def unit: T = num.zero | |
extension (t: T) def combine(other: T): T = num.plus(t, other) | |
2.2 <+> (3.3 <+> 4.4) // 9.9 | |
(2.2 <+> 3.3) <+> 4.4 // 9.9 | |
BigDecimal(3.14) <+> NumericMonoid.unit | |
NumericMonoid[BigDecimal].unit <+> BigDecimal(3.14) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment