Discrete
Discrete
represents discrete operations that can be performed on a type A
These operations are presented by the following functions.
def succ(x)
: Returns the successor value ofx
def pred(x)
: Returns the predecessor value ofx
def adj(i, j)
: Returns ifi
andj
are consecutive (succ(i) is j
)
An example of the discrete operation on integer values could be:
import cats._, cats.collections._
implicit val intDiscrete: Discrete[Int] = new Discrete[Int] {
override def succ(x: Int): Int = x + 1
override def pred(x: Int): Int = x - 1
}
// intDiscrete: Discrete[Int] = repl.MdocSession$MdocApp$$anon$1@36657141