Miranda is a modern functional programming language designed by David
Turner of the University of Kent, with lazy evaluation, polymorphic
strong typing, and a powerful module system. A program written in
Miranda is typically 5 to 15 times shorter than the corresponding
program in C or Java. The main features of Miranda are:
The built in types of the language are numbers (unbounded size integers
and double precision floating point), characters, lists, tuples, and
functions. User defined types with arbitrary substructure can be
introduced by writing type equations (so called `algebraic data types').
The language also has abstract data types and a simple but powerful
module system with type security across module boundaries.
- purely functional - no side effects
- higher order - supports functional data
- lazy - supports non strict functions and infinite data objects
- list comprehensions
- polymorphic strong typing
- abstract data types and modules
By way of a very brief example of Miranda style, here is a definition of
the list of all prime numbers (an infinite data structure) using the
sieve of Eratosthenes
primes = sieve [2..]
sieve (p:x) = p : sieve [n | n<-x ; n mod p > 0]
The expression in square brackets is a `list
comprehension' - it means list of n such that n drawn from
x and n not divisible by p. The test for divisibility uses
mod, the remainder operator. For comparison here is
the solution in
The Miranda system provides a self-contained interactive programming
environment. The Miranda compiler works in conjunction with a screen
editor (which can be vi or another editor of the user's choice). The
type system enables a high proportion of semantic errors to be detected
at compile time.
There is an online reference manual and a built in `make' feature
which automatically keeps object code files up-to-date with their
sources. The compiler generates an intermediate code based on
combinatory logic, which is executed by a fast interpreter.
Research Software Limited was awarded a British Computer Society medal
for the design of the Miranda system (BCS Awards, 1990).
The Miranda system has been developed by Research Software Ltd, of
Canterbury, England, a company formed to develop advanced functional
programming systems. The Miranda system has been extensively tested and
is running at 600 sites including 250 universities.