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 ofxdef pred(x): Returns the predecessor value ofxdef adj(i, j): Returns ifiandjare 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@4c8579