ArticleslgStudy

mathematics

ML (programming language)

ML (programming language) is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand ML (programming language) rather than just read about it. In short: ML (Meta Language) is the metalanguage developed for the Edinburgh LCF theorem prover in the 1970s. It is an early statically typed, functional language with polymorphic type inference in the Hindley–Milner style, and other features like exceptions and mutable variables.

Key takeaways

  • ML (programming language) belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect ML (programming language) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of ML (programming language) from memory before moving on to harder problems.

Reference excerpt

ML (Meta Language) is the metalanguage developed for the Edinburgh LCF theorem prover in the 1970s. It is an early statically typed, functional language with polymorphic type inference in the Hindley–Milner style, and other features like exceptions and mutable variables. ML's design in LCF directly inspired the later ML family (notably Standard ML, Caml, and their derivatives) and influenced subsequent functional language development.

History ML started development by Robin Milner upon his arrival at University of Edinburgh in 1973 with the help of research assistants Lockwood Morris and Malcolm Newey, both postdocs from Stanford who were hired by Milner. Michael Gordon, Christopher Wadsworth, and other graduate students joined in research by 1975. Historically, ML was conceived to develop proof tactics in the LCF theorem prover and succeed the previous iteration Stanford LCF, trying to solve issues regarding space utilization and proof extensibility. ML acted as both a metalanguage (hence the name) and command (REPL) language for the LCF system. PPLAMBDA, a language that was conceptually a combination of the first-order predicate calculus and the simply typed polymorphic lambda calculus, was the underlying language that theorem statements were more directly constructed in. As ML was being developed, Milner wrote the paper A theory of type polymorphism in programming in 1978, which laid out the ideas of what it meant for a program to be well-typed in the context of a polymorphic (generic) type system. He used ML as the case-study application of the theorems developed and noted the theoretical challenges that arose with development that had yet to have been solved. The design of the first version of ML was finalized, and subsequently documented in the 1979 book Edinburgh LCF by Milner along with Gordon and Wadsworth. After Edinburgh LCF was established with the publication of the same name, interest in the language grew and several implementations, all with slight alterations in design and features, were underway by several parties. Luca Cardelli created Cardelli ML, or VAX ML, which eventually grew into a standalone dialect fit for general-purpose computing, specified with the paper ML under Unix. Gérard Huet at Inria began porting the source code from Stanford Lisp to various other dialects of Lisp in "Project Formel". The port to Franz Lisp was further developed by Larry Paulson, whose version eventually was coined Cambridge LCF. This version of the LCF was subsequently updated to use an early version of Standard ML, and has been uploaded to GitHub. With the attention and excitement around ML, LCF, and other related technologies at the time, such as the contemporaneous programming language Hope, happening subsequent to the release of Edinburgh LCF and other developments at the time, a meeting was convened with the title "ML, LCF, and Hope" in November 1982. Concerns with the splintering of both design and implementation leading to duplicated work was raised in this meeting. Although Milner seemed open to the spirit of experimentation in the meeting, further discussions and meetings were had between Bernard Sufrin and Milner, where Sufrin urged Milner to unify the design of ML. These correspondences were later referenced in the second draft of Milner's proposal for Standard ML.

Overview

The most notable inspiration of the syntax of ML can be traced to ISWIM, a language that was described as "lambda calculus with syntactic sugar". ML was designed with a strong static type system that allowed the user to define abstract types with parametric polymorphism and was checked at compile-time. It also had automatic type inference, which afforded ML the ease-of-use of dynamic languages of the time such as Lisp or POP-2 by foregoing the need for explicit type annotations.

Examples The following examples are very closely derived from Edinburgh LCF, showing a rough overview of the syntax and features of ML. The # character at the start of a line denotes user input, and lines without it are system responses showing the value and its inferred type. Note that this section is not meant to act as a comprehensive set of language features that ML contains, rather a subset to give a sense for the language. Refer to Edinburgh LCF for a more rigorous definition. Expressions are evaluated by typing them followed by ;; and a return character. The identifier it holds the result of the last-evaluated expression. Bindings are introduced with let, and multiple bindings can be made simultaneously by joining them with the and keyword, or by constructing pairs (which has a product type, explored in a later example) on the right hand side, which is pattern-matched to the left:

#2+3;; 5 : int

#let x = it;; x = 5 : int

#let y = 2*5 and z = 7;; y = 10 : int z = 7 : int

#let x,y,z = y,x,2;; x = 10 : int y = 5 : int z = 2 : int Functions are defined with let. Function application is higher precedent than mathematical operators, so f 3 + 4 means (f 3) + 4. Functions defined with multiple parameters are curried, so passing one parameter into the function will return a function that will accept the second, and so on. Recursive functions require letrec so the function name is in scope within its body. The syntax for an anonymous function is similar to lambda calculus, with \ for lambda and . separating arguments from the expression:

#let add x y = x+y;; add = - : (int -> (int -> int))

#add 3;; - : (int -> int)

#it 4;; 7 : int

#letrec fact n = if n = 0 then 1 else n * fact(n-1);; fact = - : (int -> int)

#fact 4;; 24 : int

#(\x.x+1) 3;; 4 : int Lists use semicolons between elements. hd and tl are built-in functions that return the head and tail; . is cons (prepend); @ is append. Functions like hd are polymorphic—ML uses generic type variables (*, **, etc.) to express this:

#let m = [1;2;3;4];; m = [1; 2; 3; 4] : (int list)

#hd m, tl m;; 1, [2; 3; 4] : (int # (int list))

#0.m @ [5;6];; [0; 1; 2; 3; 4; 5; 6] : (int list)

#hd;; - : ((* list) -> *)

#map (\x.x*x) [1;2;3;4];; [1; 4; 9; 16] : (int list) Mutable variables are declared with letref and updated with :=. The loop keyword belongs to the if-then-loop construct, which iterates every time the if conditional fails:

#let fact n = # letref count = n and result = 1 # in if count = 0 # then result # loop count,result := count-1, count*result;; fact = - : (int -> int)

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with ML (programming language)

Start with the simplest possible case. Write down what ML (programming language) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to ML (programming language) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about ML (programming language) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of ML (programming language)

In research
ML (programming language) appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses ML (programming language) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
ML (programming language) is common in secondary-school and first-year university syllabi. It links to neighbouring topics Academic programming languages, Functional languages, High-level programming languages, so understanding it makes those chapters shorter.
In everyday life
Look for ML (programming language) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “ML (programming language)” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study ML (programming language) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what ML (programming language) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain ML (programming language) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is ML (programming language) in simple terms?

ML (Meta Language) is the metalanguage developed for the Edinburgh LCF theorem prover in the 1970s. It is an early statically typed, functional language with polymorphic type inference in the Hindley–Milner style, and other features like exceptions and mutable variables.

Why does ML (programming language) matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study ML (programming language)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on ML (programming language).

Tags

  • Academic programming languages
  • Functional languages
  • High-level programming languages
  • ML programming language family
  • Pattern matching programming languages
  • Programming languages created in 1973
  • Statically typed programming languages

Keep exploring