Created
October 19, 2016 09:59
-
-
Save mfirry/ba215193dd7e3494b643e9b3f4d6a9d8 to your computer and use it in GitHub Desktop.
cats-like implementation of CommutativeGroup for BigDecimal
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
class BigDecimalGroup extends CommutativeGroup[BigDecimal] { | |
def combine(x: BigDecimal, y: BigDecimal): BigDecimal = x + y | |
def empty: BigDecimal = 0 | |
def inverse(x: BigDecimal): BigDecimal = -x | |
override def remove(x: BigDecimal, y: BigDecimal): BigDecimal = x - y | |
} | |
implicit val catsKernelStdGroupForBigDecimal: CommutativeGroup[BigDecimal] = new BigDecimalGroup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment