flix

0.78.0

Discrete

trait Discrete[t: Type] with Order[t]Source

Trait for types that form a discrete sequence.

Every value has an immediate successor and predecessor.

The successor and predecessor functions must satisfy the following laws:

  • prev(succ(x)) == x
  • succ(prev(x)) == x
  • succ(x) > x, except at the maximum value of a bounded type (see below).

For bounded types (e.g. Int8, Int16, Int32, Int64), succ wraps around from the maximum value to the minimum value, and prev wraps around from the minimum value to the maximum value. The unbounded BigInt never wraps.

Trait for types that form a discrete sequence, and its functions.

Instances

instance Discrete[BigInt]Source
instance Discrete[Int16]Source
instance Discrete[Int32]Source
instance Discrete[Int64]Source
instance Discrete[Int8]Source

Signatures

def prev(x: t): t with Discrete[t]§ Source

Returns the predecessor of the given x.

def succ(x: t): t with Discrete[t]§ Source

Returns the successor of the given x.

Module Definitions

def adjacent(x: t, y: t): Bool with Discrete[t]§ Source

Returns true if x and y are adjacent, i.e. if one is the successor of the other.