The ST_SEQUENCE signature

« 210 Library Documentation

Overview

The ST_SEQUENCE signature is a minimalistic interface for a single-threaded sequence type. Single-threaded sequences differ from normal sequences in that they are only meant to be used in single-threaded applications — updates should only be made on a "most recent" version. However, operations on single-threaded sequences are always well-defined, regardless of context.

Interface

structure Seq : SEQUENCE

type 'a t
type 'a stseq = 'a t

exception Range

val fromSeq : 'a Seq.t → 'a stseq
val toSeq : 'a stseq → 'a Seq.t
val nth : 'a stseq → int → 'a

val update : ('a stseq * (int * 'a)) → 'a stseq
val inject : ('a stseq * (int * 'a) Seq.t) → 'a stseq

Substructures

structure Seq : SEQUENCE
Defines the underlying sequence type to and from which single-threaded sequences can be converted.

Types

type 'a t

type 'a stseq = 'a t
The abstract single-threaded sequence type 'a t has elements of type 'a. The alias 'a t is for readability.

Exceptions

exception Range
Range is raised whenever an invalid index into a single-threaded sequence is used.

Values

val fromSeq : 'a Seq.t → 'a stseq
Convert a sequence to a single-threaded sequence.
val toSeq : 'a stseq → 'a Seq.t
Convert a single-threaded sequence to a standard sequence.
val nth : 'a stseq → int → 'a
nth s i returns the $i^\text{th}$ element of $s$. Raises Range if $i$ is out of bounds.
val update : ('a stseq * (int * 'a)) → 'a stseq
update (s, (i, x)) evaluates to a new single-threaded sequence where the $i^\text{th}$ element of $s$ has been replaced by $x$, but all other elements are the same as in $s$. Raises Range if $i$ is out of bounds.
val inject : ('a stseq * (int * 'a) Seq.t) → 'a stseq
inject (s, u) evaluates to a new single-threaded sequence where, for each $(i, x) \in u$, the $i^\text{th}$ element of $s$ has been replaced by $x$, but all other elements are the same as in $s$. If there are duplicate indices in $u$, one of them "wins" non-deterministically, and the others are ignored.

Raises Range if any of the indices in $u$ is out of bounds.