encyclopegia.org

Miranda (programming language)

Miranda is a lazy, purely functional programming language designed by David Turner as a successor to his earlier programming languages SASL and KRC, using some concepts from ML and Hope. It was produced by Research Software Ltd. of England (which holds a trademark on the name Miranda) and was the first purely functional language to be commercially supported. Miranda was first released in 1985 as a fast interpreter in C for Unix-flavour operating systems, with subsequent releases in 1987 and 1989. It had a strong influence on the later Haskell language. Turner stated that the benefits of Miranda over Haskell are: "Smaller language, simpler type system, simpler arithmetic". In 2020 a version of Miranda was released as open source under a BSD licence. The code has been updated to conform to modern C standards (C11/C18) and to generate 64-bit binaries. This has been tested on operating systems including Debian, Ubuntu, WSL/Ubuntu, and macOS (Catalina).

Miranda is a lazy, purely functional programming language designed by David Turner as a successor to his earlier programming languages SASL and KRC, using some concepts from ML and Hope. It was produced by Research Software Ltd. of England (which holds a trademark on the name Miranda) and was the first purely functional language to be commercially supported. Miranda was first released in 1985 as a fast interpreter in C for Unix-flavour operating systems, with subsequent releases in 1987 and 1989. It had a strong influence on the later Haskell language. Turner stated that the benefits of Miranda over Haskell are: "Smaller language, simpler type system, simpler arithmetic". In 2020 a version of Miranda was released as open source under a BSD licence. The code has been updated to conform to modern C standards (C11/C18) and to generate 64-bit binaries. This has been tested on operating systems including Debian, Ubuntu, WSL/Ubuntu, and macOS (Catalina). this_employee = ("Folland, Mary", 10560, False, 35) The list instead is the most commonly used data structure in Miranda. It is written delimited by square brackets and with comma-separated elements, all of which must be of the same type: week_days = ["Mon","Tue","Wed","Thur","Fri"] List concatenation is ++ , subtraction is -- , construction is : , sizing is # and indexing is ! , so: days = week_days ++ ["Sat","Sun"] days = "Nil":days days!0 ⇒ "Nil" days = days -- ["Nil"] #days ⇒ 7 There are several list-building shortcuts: .. is used for lists whose elements form an arithmetic series, with the possibility for specifying an increment other than 1: fac n = product [1..n] odd_sum = sum [1,3..100] More general and powerful list-building facilities are provided by "list comprehensions" (previously known as "ZF expressions"), which come in two main forms: an expression applied to a series of terms, e.g.: squares = [ n * n | n (which is read: list of n squared where n is taken from the list of all positive integers) and a series where each term is a function of the previous one, e.g.: powers_of_2 = [ n | n As these two examples imply, Miranda allows for lists with an infinite number of elements, of which the simplest is the list of all positive integers: [1..] The notation for function application is simply juxtaposition, as in sin x . In Miranda, as in most other purely functional languages, functions are first-class citizens, which is to say that they can be passed as arguments to other functions, returned as results, or included as elements of data structures. What is more, a function with two or more parameters may be "partially parameterised", or curried, by supplying fewer arguments than the full number of parameters. This gives another function which, given the remaining parameters, will return a result. For example: add a b = a + b increment = add 1 is a roundabout way of creating a function "increment" which adds one to its argument. In reality, add 4 7 takes the two-parameter function add , applies it to 4 obtaining a single-parameter function that adds four to its argument, then applies that to 7 . Any function with two parameters (operands) can be turned into an infix operator (for example, given the definition of the add function above, the term $add is in every way equivalent to the + operator) and every infix operator taking two parameters can be turned into a corresponding function. Thus: increment = (+) 1 is the briefest way to create a function that adds one to its argument. Similarly, in half = (/ 2) reciprocal = (1 /) two single-parameter functions are generated. The interpreter understands in each case which of the divide operator's two parameters is being supplied, giving functions which respectively divide a number by two and return its reciprocal. Although Miranda is a strongly typed programming language, it does not insist on explicit type declarations. If a function's type is not explicitly declared, the interpreter infers it from the type of its parameters and how they are used within the function. In addition to the basic types ( char , num , bool ), it includes an "anything" type where the type of a parameter does not matter, as in the list-reversing function: rev [] = [] rev (a:x) = rev x ++ [a] which can be applied to a list of any data type, for which the explicit function type declaration would be: rev :: [*] -> [*] Finally, it has mechanisms for creating and managing program modules whose internal functions are invisible to programs calling those modules. ==Sample code== The following Miranda script defines the list of all sublists of a given list sublists [] = sublists (x:xs) = [[x] ++ y | y and this is a literate script for a function primes which gives the list of all prime numbers > || The infinite list of all prime numbers. The list of potential prime numbers starts as all integers from 2 onwards; as each prime is returned, all the following numbers that can exactly be divided by it are filtered out of the list of candidates. > primes = sieve [2..] > sieve (p:x) = p : sieve [n | n Here, we have some more examples max2 :: num -> num -> num max2 a b = a, if a>b fak 0 = 1 fak n = n * fak (n-1) itemnumber::[*]->num itemnumber [] = 0 itemnumber (a:x) = 1 + itemnumber x weekday::= Mo|Tu|We|Th|Fr|Sa|Su isWorkDay :: weekday -> bool isWorkDay Sa = False isWorkDay Su = False isWorkDay anyday = True tree * ::= E| N (tree *) * (tree *) nodecount :: tree * -> num nodecount E = 0 nodecount (N l w r) = nodecount l + 1 + nodecount r emptycount :: tree * -> num emptycount E = 1 emptycount (N l w r) = emptycount l + emptycount r treeExample = N ( N (N E 1 E) 3 (N E 4 E)) 5 (N (N E 6 E) 8 (N E 9 E)) weekdayTree = N ( N (N E Mo E) Tu (N E We E)) Th (N (N E Fr E) Sa (N E Su)) insert :: * -> stree * -> stree * insert x E = N E x E insert x (N l w E) = N l w x insert x (N E w r) = N x w r insert x (N l w r) = insert x l , if x * maxel E = error "empty" maxel (N l w E) = w maxel (N l w r) = maxel r minel :: tree * -> * minel E = error "empty" minel (N E w r) = w minel (N l w r) = minel l ||Traversing: going through values of tree, putting them in list preorder,inorder,postorder :: tree * -> [*] inorder E = [] inorder N l w r = inorder l ++ [w] ++ inorder r preorder E = [] preorder N l w r = [w] ++ preorder l ++ preorder r postorder E = [] postorder N l w r = postorder l ++ postorder r ++ [w] height :: tree * -> num height E = 0 height (N l w r) = 1 + max2 (height l) (height r) amount :: num -> num amount x = x ,if x >= 0 amount x = x*(-1), otherwise and :: bool -> bool -> bool and True True = True and x y = False || A AVL-Tree is a tree where the difference between the child nodes is not higher than 1 || i still have to test this isAvl :: tree * -> bool isAvl E = True isAvl (N l w r) = and (isAvl l) (isAvl r), if amount ((nodecount l) - (nodecount r)) ==References== ==External links== The currently maintained open source version of Professor Turner's interpreter for Miranda. The infinite precision math library, a large example of programming in Miranda (and Haskell).

References

No reference rows published for this article.

Cite this article

MLA

"Miranda (programming language)." encyclopegia.org, 2026, https://encyclopegia.org/wiki/miranda-programming-language. Accessed 25 November 2026.

Chicago

"Miranda (programming language)." encyclopegia.org. Accessed November 25, 2026. https://encyclopegia.org/wiki/miranda-programming-language.

APA

encyclopegia.org. (2026). Miranda (programming language). Retrieved November 25, 2026, from https://encyclopegia.org/wiki/miranda-programming-language

Accessed November 25, 2026 · CC BY-SA 4.0 · citation page · JSON

Claims

PredicateValueSource
release date1985Wikipedia

Related articles

official language

stub · references available

pan-Slavic language

stub · references available

Hawaiʻi Sign Language

stub · references available

Taiwanese Sign Language

stub · references available

Category:Programming languages

stub · references available

International Mother Language Day

stub · references available

polysynthetic language

stub · references available

Category:Films by country or language

stub · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1359705774 · 0.5 · snapshot enwiki-001359705774

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.