typelevel / algebra
1
package algebra
2
package instances
3

4
import algebra.ring._
5

6
package object bigInt extends BigIntInstances
7

8
trait BigIntInstances extends cats.kernel.instances.BigIntInstances {
9
  implicit val bigIntAlgebra: BigIntAlgebra =
10 2
    new BigIntAlgebra
11
}
12

13
class BigIntAlgebra extends CommutativeRing[BigInt] with Serializable {
14

15 2
  val zero: BigInt = BigInt(0)
16 2
  val one: BigInt = BigInt(1)
17

18 2
  def plus(a: BigInt, b: BigInt): BigInt = a + b
19 2
  def negate(a: BigInt): BigInt = -a
20 2
  override def minus(a: BigInt, b: BigInt): BigInt = a - b
21

22 2
  def times(a: BigInt, b: BigInt): BigInt = a * b
23

24 2
  override def pow(a: BigInt, k: Int): BigInt = a pow k
25

26 2
  override def fromInt(n: Int): BigInt = BigInt(n)
27
  override def fromBigInt(n: BigInt): BigInt = n
28
}

Read our documentation on viewing source code .

Loading