The INTERVAL_DOMAIN signature defines a representation of an
abstract ordered domain. It is required that the domain
consist of discrete values that are totally orders and that there
be a minimum and maximum value. This signature is used as the
argument signature for the IntervalSetFn
functor.
Synopsis
signature INTERVAL_DOMAIN
Interface
type point
val compare : (point * point) -> order
val succ : point -> point
val pred : point -> point
val isSucc : (point * point) -> bool
val minPt : point
val maxPt : point
Description
type point-
The abstract type of elements in the ordered domain.
val compare : (point * point) -> order-
compare (pt1, pt2)returns the relation between two points in the domain. val succ : point -> point-
succ itemreturns the successor toitem. Ifitemis the maximum element (maxPt), thenmaxPtis returned. val pred : point -> point-
succ itemreturns the successor toitem. Ifitemis the minimum element (minPt), thenminPtis returned. val isSucc : (point * point) -> bool-
isSucc (pt1, pt2)returnstrueifpt1is the predecessor ofpt2andpt2 is the successor of `pt1.
val minPt : point-
The minimum point in the domain.
val maxPt : point-
The maximum point in the domain.
Example
Here is an example of the 8-bit character type as an interval domain.
structure CharDom : INTERVAL_DOMAIN =
struct
type point = char
val compare = Char.compare
fun succ #"\255" = #"\255"
| succ c = chr(ord c + 1)
fun pred #"\000" = #"\000"
| pred c = chr(ord c - 1)
fun isSucc (c1, c2) = (ord c1 + 1 = ord c2)
val minPt = #"\000"
val maxPt = #"\255"
end