HOME

TheInfoList



OR:

Standard ML (SML) is a general-purpose, high-level, modular, functional
programming language A programming language is a system of notation for writing computer programs. Programming languages are described in terms of their Syntax (programming languages), syntax (form) and semantics (computer science), semantics (meaning), usually def ...
with compile-time
type checking In computer programming, a type system is a logical system comprising a set of rules that assigns a property called a ''type'' (for example, integer, floating point, string) to every '' term'' (a word, phrase, or other set of symbols). Usu ...
and
type inference Type inference, sometimes called type reconstruction, refers to the automatic detection of the type of an expression in a formal language. These include programming languages and mathematical type systems, but also natural languages in some bran ...
. It is popular for writing
compiler In computing, a compiler is a computer program that Translator (computing), translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primaril ...
s, for
programming language research Programming language theory (PLT) is a branch of computer science that deals with the design, implementation, analysis, characterization, and classification of formal languages known as programming languages. Programming language theory is clos ...
, and for developing theorem provers. Standard ML is a modern dialect of ML, the language used in the
Logic for Computable Functions Logic for Computable Functions (LCF) is an interactive automated theorem prover developed at Stanford and Edinburgh by Robin Milner and collaborators in early 1970s, based on the theoretical foundation of logic of computable functions previously ...
(LCF) theorem-proving project. It is distinctive among widely used languages in that it has a
formal specification In computer science, formal specifications are mathematically based techniques whose purpose is to help with the implementation of systems and software. They are used to describe a system, to analyze its behavior, and to aid in its design by verify ...
, given as
typing rule In type theory, a typing rule is an inference rule that describes how a type system assigns a type to a syntactic construction. These rules may be applied by the type system to determine if a program is well-typed and what type expressions ha ...
s and
operational semantics Operational semantics is a category of formal programming language semantics in which certain desired properties of a program, such as correctness, safety or security, are verified by constructing proofs from logical statements about its exec ...
in ''The Definition of Standard ML''.


Language

Standard ML is a functional
programming language A programming language is a system of notation for writing computer programs. Programming languages are described in terms of their Syntax (programming languages), syntax (form) and semantics (computer science), semantics (meaning), usually def ...
with some impure features. Programs written in Standard ML consist of expressions in contrast to statements or commands, although some expressions of type unit are only evaluated for their
side-effects In medicine, a side effect is an effect of the use of a medicinal drug or other treatment, usually adverse but sometimes beneficial, that is unintended. Herbal and traditional medicines also have side effects. A drug or procedure usually used ...
.


Functions

Like all functional languages, a key feature of Standard ML is the function, which is used for abstraction. The factorial function can be expressed as follows: fun factorial n = if n = 0 then 1 else n * factorial (n - 1)


Type inference

An SML compiler must infer the static type without user-supplied type annotations. It has to deduce that is only used with integer expressions, and must therefore itself be an integer, and that all terminal expressions are integer expressions.


Declarative definitions

The same function can be expressed with clausal function definitions where the ''if''-''then''-''else'' conditional is replaced with templates of the factorial function evaluated for specific values: fun factorial 0 = 1 , factorial n = n * factorial (n - 1)


Imperative definitions

or iteratively: fun factorial n = let val i = ref n and acc = ref 1 in while !i > 0 do (acc := !acc * !i; i := !i - 1); !acc end


Lambda functions

or as a lambda function: val rec factorial = fn 0 => 1 , n => n * factorial (n - 1) Here, the keyword introduces a binding of an identifier to a value, introduces an
anonymous function In computer programming, an anonymous function (function literal, expression or block) is a function definition that is not bound to an identifier. Anonymous functions are often arguments being passed to higher-order functions or used for const ...
, and allows the definition to be self-referential.


Local definitions

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. Using a local function, it can be rewritten in a more efficient tail-recursive style: local fun loop (0, acc) = acc , loop (m, acc) = loop (m - 1, m * acc) in fun factorial n = loop (n, 1) end


Type synonyms

A type synonym is defined with the keyword . Here is a type synonym for points on a plane, and functions computing the distances between two points, and the area of a triangle with the given corners as per
Heron's formula In geometry, Heron's formula (or Hero's formula) gives the area of a triangle in terms of the three side lengths Letting be the semiperimeter of the triangle, s = \tfrac12(a + b + c), the area is A = \sqrt. It is named after first-century ...
. (These definitions will be used in subsequent examples). type loc = real * real fun square (x : real) = x * x fun dist (x, y) (x', y') = Math.sqrt (square (x' - x) + square (y' - y)) fun heron (a, b, c) = let val x = dist a b val y = dist b c val z = dist a c val s = (x + y + z) / 2.0 in Math.sqrt (s * (s - x) * (s - y) * (s - z)) end


Algebraic datatypes

Standard ML provides strong support for algebraic datatypes (ADT). A
data type In computer science and computer programming, a data type (or simply type) is a collection or grouping of data values, usually specified by a set of possible values, a set of allowed operations on these values, and/or a representation of these ...
can be thought of as a
disjoint union In mathematics, the disjoint union (or discriminated union) A \sqcup B of the sets and is the set formed from the elements of and labelled (indexed) with the name of the set from which they come. So, an element belonging to both and appe ...
of tuples (or a "sum of products"). They are easy to define and easy to use, largely because of
pattern matching In computer science, pattern matching is the act of checking a given sequence of tokens for the presence of the constituents of some pattern. In contrast to pattern recognition, the match usually must be exact: "either it will or will not be a ...
, and most Standard ML implementations' pattern-exhaustiveness checking and pattern redundancy checking. In
object-oriented programming Object-oriented programming (OOP) is a programming paradigm based on the concept of '' objects''. Objects can contain data (called fields, attributes or properties) and have actions they can perform (called procedures or methods and impl ...
languages, a disjoint union can be expressed as
class Class, Classes, or The Class may refer to: Common uses not otherwise categorized * Class (biology), a taxonomic rank * Class (knowledge representation), a collection of individuals or objects * Class (philosophy), an analytical concept used d ...
hierarchies. However, in contrast to
class hierarchies A class hierarchy or inheritance tree in computer science is a classification of object types, denoting objects as the instantiations of classes (class is like a blueprint, the object is what is built from that blueprint) inter-relating the var ...
, ADTs are closed. Thus, the extensibility of ADTs is orthogonal to the extensibility of class hierarchies. Class hierarchies can be extended with new subclasses which implement the same interface, while the functions of ADTs can be extended for the fixed set of constructors. See expression problem. A datatype is defined with the keyword , as in: datatype shape = Circle of loc * real (* center and radius *) , Square of loc * real (* upper-left corner and side length; axis-aligned *) , Triangle of loc * loc * loc (* corners *) Note that a type synonym cannot be recursive; datatypes are necessary to define recursive constructors. (This is not at issue in this example.)


Pattern matching

Patterns are matched in the order in which they are defined. C programmers can use
tagged union In computer science, a tagged union, also called a variant, variant record, choice type, discriminated union, disjoint union, sum type, or coproduct, is a data structure used to hold a value that could take on several different, but fixed, types. ...
s, dispatching on tag values, to do what ML does with datatypes and pattern matching. Nevertheless, while a C program decorated with appropriate checks will, in a sense, be as robust as the corresponding ML program, those checks will of necessity be dynamic; ML's static checks provide strong guarantees about the correctness of the program at compile time. Function arguments can be defined as patterns as follows: fun area (Circle (_, r)) = Math.pi * square r , area (Square (_, s)) = square s , area (Triangle p) = heron p (* see above *) The so-called "clausal form" of function definition, where arguments are defined as patterns, is merely
syntactic sugar In computer science, syntactic sugar is syntax within a programming language that is designed to make things easier to read or to express. It makes the language "sweeter" for human use: things can be expressed more clearly, more concisely, or in an ...
for a case expression: fun area shape = case shape of Circle (_, r) => Math.pi * square r , Square (_, s) => square s , Triangle p => heron p


Exhaustiveness checking

Pattern-exhaustiveness checking will make sure that each constructor of the datatype is matched by at least one pattern. The following pattern is not exhaustive: fun center (Circle (c, _)) = c , center (Square ((x, y), s)) = (x + s / 2.0, y + s / 2.0) There is no pattern for the case in the function. The compiler will issue a warning that the case expression is not exhaustive, and if a is passed to this function at runtime, will be raised.


Redundancy checking

The pattern in the second clause of the following (meaningless) function is redundant: fun f (Circle ((x, y), r)) = x + y , f (Circle _) = 1.0 , f _ = 0.0 Any value that would match the pattern in the second clause would also match the pattern in the first clause, so the second clause is unreachable. Therefore, this definition as a whole exhibits redundancy, and causes a compile-time warning. The following function definition is exhaustive and not redundant: val hasCorners = fn (Circle _) => false , _ => true If control gets past the first pattern (), we know the shape must be either a or a . In either of those cases, we know the shape has corners, so we can return without discerning the actual shape.


Higher-order functions

Functions can consume functions as arguments: fun map f (x, y) = (f x, f y) Functions can produce functions as return values: fun constant k = (fn _ => k) Functions can also both consume and produce functions: fun compose (f, g) = (fn x => f (g x)) The function from the basis
library A library is a collection of Book, books, and possibly other Document, materials and Media (communication), media, that is accessible for use by its members and members of allied institutions. Libraries provide physical (hard copies) or electron ...
is one of the most commonly used higher-order functions in Standard ML: fun map _ [] = [] , map f (x :: xs) = f x :: map f xs A more efficient implementation with tail-recursive : fun map f = List.rev o List.foldl (fn (x, acc) => f x :: acc) []


Exceptions

Exceptions are raised with the keyword and handled with the pattern matching construct. The exception system can implement non-local exit; this optimization technique is suitable for functions like the following. local exception Zero; val p = fn (0, _) => raise Zero , (a, b) => a * b in fun prod xs = List.foldl p 1 xs handle Zero => 0 end When is raised, control leaves the function altogether. Consider the alternative: the value 0 would be returned, it would be multiplied by the next integer in the list, the resulting value (inevitably 0) would be returned, and so on. The raising of the exception allows control to skip over the entire chain of frames and avoid the associated computation. Note the use of the underscore () as a wildcard pattern. The same optimization can be obtained with a
tail call In computer science, a tail call is a subroutine call performed as the final action of a procedure. If the target of a tail is the same subroutine, the subroutine is said to be tail recursive, which is a special case of direct recursion. Tail recur ...
. local fun p a (0 :: _) = 0 , p a (x :: xs) = p (a * x) xs , p a [] = a in val prod = p 1 end


Module system

Standard ML's advanced module system allows programs to be decomposed into hierarchically organized ''structures'' of logically related type and value definitions. Modules provide not only
namespace In computing, a namespace is a set of signs (''names'') that are used to identify and refer to objects of various kinds. A namespace ensures that all of a given set of objects have unique names so that they can be easily identified. Namespaces ...
control but also abstraction, in the sense that they allow the definition of
abstract data type In computer science, an abstract data type (ADT) is a mathematical model for data types, defined by its behavior (semantics) from the point of view of a '' user'' of the data, specifically in terms of possible values, possible operations on data ...
s. Three main syntactic constructs comprise the module system: signatures, structures and functors.


Signatures

A ''signature'' is an interface, usually thought of as a type for a structure; it specifies the names of all entities provided by the structure, the
arity In logic, mathematics, and computer science, arity () is the number of arguments or operands taken by a function, operation or relation. In mathematics, arity may also be called rank, but this word can have many other meanings. In logic and ...
of each type component, the type of each value component, and the signature of each substructure. The definitions of type components are optional; type components whose definitions are hidden are ''abstract types''. For example, the signature for a queue may be: signature QUEUE = sig type 'a queue exception QueueError; val empty : 'a queue val isEmpty : 'a queue -> bool val singleton : 'a -> 'a queue val fromList : 'a list -> 'a queue val insert : 'a * 'a queue -> 'a queue val peek : 'a queue -> 'a val remove : 'a queue -> 'a * 'a queue end This signature describes a module that provides a polymorphic type , , and values that define basic operations on queues.


Structures

A ''structure'' is a module; it consists of a collection of types, exceptions, values and structures (called ''substructures'') packaged together into a logical unit. A queue structure can be implemented as follows: structure TwoListQueue :> QUEUE = struct type 'a queue = 'a list * 'a list exception QueueError; val empty = ([], []) fun isEmpty ([], []) = true , isEmpty _ = false fun singleton a = ([], [a]) fun fromList a = ([], a) fun insert (a, ([], [])) = singleton a , insert (a, (ins, outs)) = (a :: ins, outs) fun peek (_, []) = raise QueueError , peek (ins, outs) = List.hd outs fun remove (_, []) = raise QueueError , remove (ins, [a]) = (a, ([], List.rev ins)) , remove (ins, a :: outs) = (a, (ins, outs)) end This definition declares that implements . Furthermore, the ''opaque ascription'' denoted by states that any types which are not defined in the signature (i.e. ) should be abstract, meaning that the definition of a queue as a pair of lists is not visible outside the module. The structure implements all of the definitions in the signature. The types and values in a structure can be accessed with "dot notation": val q : string TwoListQueue.queue = TwoListQueue.empty val q' = TwoListQueue.insert (Real.toString Math.pi, q)


Functors

A ''functor'' is a function from structures to structures; that is, a functor accepts one or more arguments, which are usually structures of a given signature, and produces a structure as its result. Functors are used to implement generic data structures and algorithms. One popular algorithm for
breadth-first search Breadth-first search (BFS) is an algorithm for searching a tree data structure for a node that satisfies a given property. It starts at the tree root and explores all nodes at the present depth prior to moving on to the nodes at the next dept ...
of trees makes use of queues. Here is a version of that algorithm parameterized over an abstract queue structure: (* after Okasaki, ICFP, 2000 *) functor BFS (Q: QUEUE) = struct datatype 'a tree = E , T of 'a * 'a tree * 'a tree local fun bfsQ q = if Q.isEmpty q then [] else search (Q.remove q) and search (E, q) = bfsQ q , search (T (x, l, r), q) = x :: bfsQ (insert (insert q l) r) and insert q a = Q.insert (a, q) in fun bfs t = bfsQ (Q.singleton t) end end structure QueueBFS = BFS (TwoListQueue) Within , the representation of the queue is not visible. More concretely, there is no way to select the first list in the two-list queue, if that is indeed the representation being used. 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.


Code examples

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


Hello, world!

The following is a
"Hello, World!" program A "Hello, World!" program is usually a simple computer program that emits (or displays) to the screen (often the Console application, console) a message similar to "Hello, World!". A small piece of code in most general-purpose programming languag ...
:


Algorithms


Insertion sort

Insertion sort for (ascending) can be expressed concisely as follows: fun insert (x, []) = [x] , insert (x, h :: t) = sort x (h, t) and sort x (h, t) = if x < h then [x, h] @ t else h :: insert (x, t) val insertionsort = List.foldl insert []


Mergesort

Here, the classic mergesort algorithm is implemented in three functions: split, merge and mergesort. Also note the absence of types, with the exception of the syntax and which signify lists. This code will sort lists of any type, so long as a consistent ordering function is defined. Using Hindley–Milner type inference, the types of all variables can be inferred, even complicated types such as that of the function . Split is implemented with a stateful closure which alternates between and , ignoring the input: fun alternator = let val state = ref true in fn a => !state before state := not (!state) end (* Split a list into near-halves which will either be the same length, * or the first will have one more element than the other. * Runs in O(n) time, where n = , xs, . *) fun split xs = List.partition (alternator ) xs Merge Merge uses a local function loop for efficiency. The inner is defined in terms of cases: when both lists are non-empty () and when one list is empty (). This function merges two sorted lists into one sorted list. Note how the accumulator is built backwards, then reversed before being returned. This is a common technique, since is represented as a
linked list In computer science, a linked list is a linear collection of data elements whose order is not given by their physical placement in memory. Instead, each element points to the next. It is a data structure consisting of a collection of nodes whi ...
; this technique requires more clock time, but the
asymptotics In mathematical analysis, asymptotic analysis, also known as asymptotics, is a method of describing limiting behavior. As an illustration, suppose that we are interested in the properties of a function as becomes very large. If , then as bec ...
are not worse. (* Merge two ordered lists using the order cmp. * Pre: each list must already be ordered per cmp. * Runs in O(n) time, where n = , xs, + , ys, . *) fun merge cmp (xs, []) = xs , merge cmp (xs, y :: ys) = let fun loop (a, acc) (xs, []) = List.revAppend (a :: acc, xs) , loop (a, acc) (xs, y :: ys) = if cmp (a, y) then loop (y, a :: acc) (ys, xs) else loop (a, y :: acc) (xs, ys) in loop (y, []) (ys, xs) end Mergesort The main function: fun ap f (x, y) = (f x, f y) (* Sort a list in according to the given ordering operation cmp. * Runs in O(n log n) time, where n = , xs, . *) fun mergesort cmp [] = [] , mergesort cmp [x] = [x] , mergesort cmp xs = (merge cmp o ap (mergesort cmp) o split) xs


Quicksort

Quicksort can be expressed as follows. is a [ closure that consumes an order operator . infix << fun quicksort (op <<) = let fun part p = List.partition (fn x => x << p) fun sort [] = [] , sort (p :: xs) = join p (part p xs) and join p (l, r) = sort l @ p :: sort r in sort end


Expression interpreter

Note the relative ease with which a small expression language can be defined and processed: exception TyErr; datatype ty = IntTy , BoolTy fun unify (IntTy, IntTy) = IntTy , unify (BoolTy, BoolTy) = BoolTy , unify (_, _) = raise TyErr datatype exp = True , False , Int of int , Not of exp , Add of exp * exp , If of exp * exp * exp fun infer True = BoolTy , infer False = BoolTy , infer (Int _) = IntTy , infer (Not e) = (assert e BoolTy; BoolTy) , infer (Add (a, b)) = (assert a IntTy; assert b IntTy; IntTy) , infer (If (e, t, f)) = (assert e BoolTy; unify (infer t, infer f)) and assert e t = unify (infer e, t) fun eval True = True , eval False = False , eval (Int n) = Int n , eval (Not e) = if eval e = True then False else True , eval (Add (a, b)) = (case (eval a, eval b) of (Int x, Int y) => Int (x + y)) , eval (If (e, t, f)) = eval (if eval e = True then t else f) fun run e = (infer e; SOME (eval e)) handle TyErr => NONE Example usage on well-typed and ill-typed expressions: val SOME (Int 3) = run (Add (Int 1, Int 2)) (* well-typed *) val NONE = run (If (Not (Int 1), True, False)) (* ill-typed *)


Arbitrary-precision integers

The module provides arbitrary-precision integer arithmetic. Moreover, integer literals may be used as arbitrary-precision integers without the programmer having to do anything. The following program implements an arbitrary-precision factorial function:


Partial application

Curried functions have many applications, such as eliminating redundant code. For example, a module may require functions of type , but it is more convenient to write functions of type where there is a fixed relationship between the objects of type and . A function of type can factor out this commonality. This is an example of the
adapter pattern In software engineering, the adapter pattern is a software design pattern (also known as wrapper, an alternative naming shared with the decorator pattern) that allows the interface of an existing class to be used as another interface. It is oft ...
. In this example, computes the numerical derivative of a given function at point : - fun d delta f x = (f (x + delta) - f (x - delta)) / (2.0 * delta) val d = fn : real -> (real -> real) -> real -> real The type of indicates that it maps a "float" onto a function with the type . This allows us to partially apply arguments, known as
currying In mathematics and computer science, currying is the technique of translating a function that takes multiple arguments into a sequence of families of functions, each taking a single argument. In the prototypical example, one begins with a functi ...
. In this case, function can be specialised by partially applying it with the argument . A good choice for when using this algorithm is the cube root of the machine epsilon. - val d' = d 1E~8; val d' = fn : (real -> real) -> real -> real The inferred type indicates that expects a function with the type as its first argument. We can compute an approximation to the derivative of f(x) = x^3-x-1 at x=3. The correct answer is f'(3) = 27-1 = 26. - d' (fn x => x * x * x - x - 1.0) 3.0; val it = 25.9999996644 : real


Libraries


Standard

The Basis Library has been standardized and ships with most implementations. It provides modules for trees, arrays, and other data structures, and
input/output In computing, input/output (I/O, i/o, or informally io or IO) is the communication between an information processing system, such as a computer, and the outside world, such as another computer system, peripherals, or a human operator. Inputs a ...
and system interfaces.


Third party

For numerical computing, a Matrix module exists (but is currently broken), https://www.cs.cmu.edu/afs/cs/project/pscico/pscico/src/matrix/README.html. For graphics, cairo-sml is an open source interface to the
Cairo Cairo ( ; , ) is the Capital city, capital and largest city of Egypt and the Cairo Governorate, being home to more than 10 million people. It is also part of the List of urban agglomerations in Africa, largest urban agglomeration in Africa, L ...
graphics library. For machine learning, a library for graphical models exists.


Implementations

Implementations of Standard ML include the following: Standard
HaMLet
a Standard ML interpreter that aims to be an accurate and accessible reference implementation of the standard * MLton
mlton.org
: a whole-program optimizing compiler which strictly conforms to the Definition and produces very fast code compared to other ML implementations, including backends for
LLVM LLVM, also called LLVM Core, is a target-independent optimizer and code generator. It can be used to develop a Compiler#Front end, frontend for any programming language and a Compiler#Back end, backend for any instruction set architecture. LLVM i ...
and C
Moscow ML
a light-weight implementation, based on the
Caml Caml (originally an acronym for Categorical Abstract Machine Language) is a multi-paradigm, general-purpose, high-level, functional programming language which is a dialect of the ML programming language family. Caml was developed in France ...
Light runtime engine which implements the full Standard ML language, including modules and much of the basis library
Poly/ML
a full implementation of Standard ML that produces fast code and supports multicore hardware (via Portable Operating System Interface (
POSIX The Portable Operating System Interface (POSIX; ) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines application programming interfaces (APIs), along with comm ...
) threads); its runtime system performs parallel
garbage collection Waste collection is a part of the process of waste management. It is the transfer of solid waste from the point of use and disposal to the point of treatment or landfill. Waste collection also includes the curbside collection of recyclable ...
and online sharing of immutable substructures. *
Standard ML of New Jersey Standard ML of New Jersey (SML/NJ; Standard Meta-Language of New Jersey) is a compiler and integrated development environment for the programming language Standard ML. It is written in Standard ML, except for the runtime system in C language. It ...

smlnj.org
: a full compiler, with associated libraries, tools, an interactive shell, and documentation with support for
Concurrent ML Concurrent ML (CML) is a multi-paradigm, general-purpose, high-level, functional programming language. It is a dialect of the programming language ML which is a concurrent extension of the Standard ML language, characterized by its ability ...

SML.NET
a Standard ML compiler for the
Common Language Runtime The Common Language Runtime (CLR), the virtual machine component of Microsoft .NET Framework, manages the execution of .NET programs. Just-in-time compilation converts the managed code (compiled intermediate language code) into machine instr ...
with extensions for linking with other
.NET The .NET platform (pronounced as "''dot net"'') is a free and open-source, managed code, managed computer software framework for Microsoft Windows, Windows, Linux, and macOS operating systems. The project is mainly developed by Microsoft emplo ...
framework code
ML Kit
: an implementation based very closely on the Definition, integrating a garbage collector (which can be disabled) and region-based memory management with automatic inference of regions, aiming to support real-time applications Derivative *
Alice Alice may refer to: * Alice (name), most often a feminine given name, but also used as a surname Literature * Alice (''Alice's Adventures in Wonderland''), a character in books by Lewis Carroll * ''Alice'' series, children's and teen books by ...
: an interpreter for Standard ML by Saarland University with support for parallel programming using futures,
lazy evaluation In programming language theory, lazy evaluation, or call-by-need, is an evaluation strategy which delays the evaluation of an Expression (computer science), expression until its value is needed (non-strict evaluation) and which avoids repeated eva ...
,
distributed computing Distributed computing is a field of computer science that studies distributed systems, defined as computer systems whose inter-communicating components are located on different networked computers. The components of a distributed system commu ...
via
remote procedure call In distributed computing, a remote procedure call (RPC) is when a computer program causes a procedure (subroutine) to execute in a different address space (commonly on another computer on a shared computer network), which is written as if it were a ...
s and
constraint programming Constraint programming (CP) is a paradigm for solving combinatorial problems that draws on a wide range of techniques from artificial intelligence, computer science, and operations research. In constraint programming, users declaratively state t ...

SML#
an extension of SML providing record polymorphism and C language interoperability. It is a conventional native compiler and its name is ''not'' an allusion to running on the .NET framework
SOSML
an implementation written in
TypeScript TypeScript (abbreviated as TS) is a high-level programming language that adds static typing with optional type annotations to JavaScript. It is designed for developing large applications and transpiles to JavaScript. It is developed by Micr ...
, supporting most of the SML language and select parts of the basis library Research
CakeML
is a REPL version of ML with formally verified runtime and translation to assembler. *
Isabelle Isabel is a female name of Iberian origin. Isabelle is a name that is similar, but it is of French origin. It originates as the medieval Spanish form of '' Elisabeth'' (ultimately Hebrew ''Elisheba''). Arising in the 12th century, it became popul ...

Isabelle/ML
) integrates parallel Poly/ML into an interactive theorem prover, with a sophisticated IDE (based on jEdit) for official Standard ML (SML'97), the Isabelle/ML dialect, and the proof language. Starting with Isabelle2016, there is also a source-level debugger for ML. * Poplog implements a version of Standard ML, along with
Common Lisp Common Lisp (CL) is a dialect of the Lisp programming language, published in American National Standards Institute (ANSI) standard document ''ANSI INCITS 226-1994 (S2018)'' (formerly ''X3.226-1994 (R1999)''). The Common Lisp HyperSpec, a hyperli ...
and
Prolog Prolog is a logic programming language that has its origins in artificial intelligence, automated theorem proving, and computational linguistics. Prolog has its roots in first-order logic, a formal logic. Unlike many other programming language ...
, allowing mixed language programming; all are implemented in
POP-11 POP-11 is a Reflective programming, reflective, Dynamic compilation, incrementally compiled programming language with many of the features of an interpreted language. It is the core language of the Poplog Computer programming, programming system ...
, which is compiled incrementally.
TILT
is a full certifying compiler for Standard ML which uses typed intermediate languages to optimize code and ensure correctness, and can compile to
typed assembly language In computer science, a typed assembly language (TAL) is an assembly language that is extended to include a method of annotating the datatype of each value that is manipulated by the code. These annotations can then be used by a program (type checke ...
. All of these implementations are
open-source Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use and view the source code, design documents, or content of the product. The open source model is a decentrali ...
and freely available. Most are implemented themselves in Standard ML. There are no longer any commercial implementations;
Harlequin Harlequin (, , ; , ) is the best-known of the comic servant characters (Zanni) from the Italian commedia dell'arte, associated with the city of Bergamo. The role is traditionally believed to have been introduced by the Italian actor-manager Zan ...
, now defunct, once produced a commercial IDE and compiler called MLWorks which passed on to Xanalys and was later open-sourced after it was acquired by Ravenbrook Limited on April 26, 2013.


Major projects using SML

The IT University of Copenhagen's entire
enterprise architecture Enterprise architecture (EA) is a business function concerned with the structures and behaviours of a business, especially business roles and processes that create and use business data. The international definition according to the Federation of ...
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. The
proof assistant In computer science and mathematical logic, a proof assistant or interactive theorem prover is a software tool to assist with the development of formal proofs by human–machine collaboration. This involves some sort of interactive proof edi ...
s HOL4,
Isabelle Isabel is a female name of Iberian origin. Isabelle is a name that is similar, but it is of French origin. It originates as the medieval Spanish form of '' Elisabeth'' (ultimately Hebrew ''Elisheba''). Arising in the 12th century, it became popul ...
,
LEGO Lego (, ; ; stylised as LEGO) is a line of plastic construction toys manufactured by the Lego Group, a privately held company based in Billund, Denmark. Lego consists of variously coloured interlocking plastic bricks made of acrylonitri ...
, and
Twelf Twelf is an implementation of the logical framework LF developed by Frank Pfenning and Carsten Schürmann at Carnegie Mellon University. It is used for logic programming and for the formalization of programming language theory. Introduction At ...
are written in Standard ML. It is also used by compiler writers and
integrated circuit design Integrated circuit design, semiconductor design, chip design or IC design, is a sub-field of electronics engineering, encompassing the particular Boolean logic, logic and circuit design techniques required to design integrated circuits (ICs). A ...
ers such as ARM.


See also

*
Declarative programming In computer science, declarative programming is a programming paradigm—a style of building the structure and elements of computer programs—that expresses the logic of a computation without describing its control flow. Many languages that ap ...


References


External links

About Standard ML
Revised definition

Standard ML Family GitHub Project




About successor ML
successor ML (sML)
evolution of ML using Standard ML as a starting point
HaMLet on GitHub
reference implementation for successor ML Practical
Basic introductory tutorial

Examples in Rosetta Code
Academic
Programming in Standard ML


{{Authority control High-level programming languages Functional languages Procedural programming languages ML programming language family Programming languages created in 1983