ST_SEQUENCE
signature
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.
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
structure Seq :
SEQUENCE
type 'a t
type 'a stseq = 'a t
'a t
has elements of type 'a
.
The alias 'a t
is for readability.exception Range
Range
is raised whenever an
invalid index into a single-threaded sequence is used.val fromSeq :
'a Seq.t → 'a stseq
val toSeq :
'a stseq → 'a Seq.t
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.