This typeclass provides the function succ? : α → Option α that computes the successor of
elements of α, or none if no successor exists.
It also provides the function succMany?, which computes n-th successors.
succ? is expected to be acyclic: No element is its own transitive successor.
If α is ordered, then every element larger than a : α should be a transitive successor of a.
These properties and the compatibility of succ? with succMany? are encoded in the typeclasses
LawfulUpwardEnumerable, LawfulUpwardEnumerableLE and LawfulUpwardEnumerableLT.
- succ? : α → Option αMaps elements of αto their successor, or none if no successor exists.
- Maps elements of - αto their- n-th successor, or none if no successor exists. This should semantically behave like repeatedly applying- succ?, but it might be more efficient.- LawfulUpwardEnumerableensures the compatibility with- succ?.- If no other implementation is provided in - UpwardEnumerableinstance,- succMany?repeatedly applies- succ?.
Instances
According to UpwardEnumerable.LE, a is less than or equal to b if b is a or a transitive
successor of a.
Instances For
According to UpwardEnumerable.LT, a is less than b if b is a proper transitive successor of
a. 'Proper' means that b is the n-th successor of a, where n > 0.
Given LawfulUpwardEnumerable α, no element of α is less than itself.
Instances For
The typeclass Least? α optionally provides a smallest element of α, least? : Option α.
The main use case of this typeclass is to use it in combination with UpwardEnumerable to
obtain a (possibly infinite) ascending enumeration of all elements of α.
- least? : Option α
Instances
This typeclass ensures that an UpwardEnumerable α instance is well-behaved.
- ne_of_lt (a b : α) : UpwardEnumerable.LT a b → a ≠ bThere is no cyclic chain of successors. 
- The - 0-th successor of- ais- aitself.
- The - n + 1-th successor of- ais the successor of the- n-th successor, given that said successors actually exist.
Instances
This propositional typeclass ensures that UpwardEnumerable.succ? will never return none.
In other words, it ensures that there will always be a successor.
Instances
Maps elements of α to their immediate successor.
Equations
- Std.PRange.succ a = (Std.PRange.succ? a).get ⋯
Instances For
Maps elements of α to their n-th successor. This should semantically behave like repeatedly
applying succ, but it might be more efficient.
This function uses an UpwardEnumerable α instance.
LawfulUpwardEnumerable α ensures the compatibility with succ and succ?.
If no other implementation is provided in UpwardEnumerable instance, succMany? repeatedly applies succ?.
Equations
- Std.PRange.succMany n a = (Std.PRange.succMany? n a).get ⋯
Instances For
This typeclass ensures that an UpwardEnumerable α instance is compatible with ≤.
In this case, UpwardEnumerable α fully characterizes the LE α instance.
- ais less than or equal to- bif and only if- bis either- aor a transitive successor of- a.
Instances
Equations
Instances For
This typeclass ensures that an UpwardEnumerable α instance is compatible with <.
In this case, UpwardEnumerable α fully characterizes the LT α instance.
- ais less than- bif and only if- bis a proper transitive successor of- a.
Instances
Equations
Instances For
Equations
- ⋯ = ⋯
Instances For
This typeclass ensures that an UpwardEnumerable α instance is compatible with a Least? α
instance. For nonempty α, it ensures that least? has a value and that every other value is
a transitive successor of it.
- For nonempty - α,- least?has a value and every other value is a transitive successor of it.