Standard ML

It is popular for writing compilers, for programming language research, and for developing theorem provers.

It is distinctive among widely used languages in that it has a formal specification, given as typing rules and operational semantics in The Definition of Standard ML.

The encapsulation of an invariant-preserving tail-recursive tight loop with one or more accumulator parameters within an invariant-free outer function, as seen here, is a common idiom in Standard ML.

Standard ML provides strong support for algebraic datatypes (ADT).

A data type can be thought of as a disjoint union of tuples (or a "sum of products").

In object-oriented programming languages, a disjoint union can be expressed as class hierarchies.

The compiler will issue a warning that the case expression is not exhaustive, and if a Triangle is passed to this function at runtime, exception Match will be raised.

The following function definition is exhaustive and not redundant: If control gets past the first pattern (Circle), we know the shape must be either a Square or a Triangle.

The exception system can implement non-local exit; this optimization technique is suitable for functions like the following.

The raising of the exception allows control to skip over the entire chain of frames and avoid the associated computation.

Standard ML's advanced module system allows programs to be decomposed into hierarchically organized structures of logically related type and value definitions.

Three main syntactic constructs comprise the module system: signatures, structures and functors.

This data abstraction mechanism makes the breadth-first search truly agnostic to the queue's implementation.

This is in general desirable; in this case, the queue structure can safely maintain any logical invariants on which its correctness depends behind the bulletproof wall of abstraction.

Snippets of SML code are most easily studied by entering them into an interactive top-level.

Also note the absence of types, with the exception of the syntax op :: and [] which signify lists.

This code will sort lists of any type, so long as a consistent ordering function cmp is defined.

A good choice for delta when using this algorithm is the cube root of the machine epsilon.

It provides modules for trees, arrays, and other data structures, and input/output and system interfaces.

The IT University of Copenhagen's entire enterprise architecture is implemented in around 100,000 lines of SML, including staff records, payroll, course administration and feedback, student project management, and web-based self-service interfaces.

[8] The proof assistants HOL4, Isabelle, LEGO, and Twelf are written in Standard ML.