typelevel / algebra
1
package algebra
2
package instances
3

4
import algebra.lattice._
5
import algebra.ring._
6

7
package object long extends LongInstances
8

9
trait LongInstances extends cats.kernel.instances.LongInstances {
10
  implicit val longAlgebra: LongAlgebra =
11 2
    new LongAlgebra
12

13
  val LongMinMaxLattice: BoundedDistributiveLattice[Long] =
14 2
    BoundedDistributiveLattice.minMax[Long](Long.MinValue, Long.MaxValue)
15
}
16

17
class LongAlgebra extends CommutativeRing[Long] with Serializable {
18

19 2
  def zero: Long = 0
20 2
  def one: Long = 1
21

22 2
  def plus(x: Long, y: Long): Long = x + y
23 2
  def negate(x: Long): Long = -x
24 2
  override def minus(x: Long, y: Long): Long = x - y
25

26 2
  def times(x: Long, y: Long): Long = x * y
27

28 2
  override def pow(x: Long, y: Int): Long = StaticMethods.pow(x, y.toLong)
29

30 2
  override def fromInt(n: Int): Long = n.toLong
31 2
  override def fromBigInt(n: BigInt): Long = n.toLong
32
}

Read our documentation on viewing source code .

Loading