The INTERVAL_DOMAIN signature
Author: John Reppy
Keywords: Standard ML, SML, SML/NJ Library

The SML of NJ Library
The `INTERVAL_DOMAIN` signature

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 item` returns the successor to `item`. If `item` is the maximum element (`maxPt`), then `maxPt` is returned.

`val pred : point -> point`

  `succ item` returns the successor to `item`. If `item` is the minimum element (`minPt`), then `minPt` is returned.

`val isSucc : (point * point) -> bool`

  `isSucc (pt1, pt2)` returns `true` if `pt1` is the predecessor of `pt2` and `pt2 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

## See Also

`IntervalSetFn`, The Util Library

SML/NJ Version 110.99.9 (November 4, 2025)
Last updated 2025-11-04 15:48:25 UTC