Miranda (programming language): Difference between revisions

Content deleted Content added
Template:More footnotes update > Template:More footnotes needed. Template:Infobox programming language parameter: reorder, standardize, conform to master template. Whitespace characters cut to standardize, aid work via small screens. WP:LINKs: update-standardizes, needless WP:PIPEs > WP:NOPIPEs.
Line 1:
{{moreMore footnotes needed|date=September 2016}}
{{Infobox programming language
| name = Miranda
| logo = [[File:Miranda logo (programming language).jpg]]
| logo caption =
| screenshot =
| screenshot caption =
| file ext =
| paradigm = [[lazyLazy evaluation|lazy]], [[functionalFunctional programming|functional]], [[declarativeDeclarative programming|declarative]]
| scope =
| designer = [[David Turner (computer scientist)|David Turner]]
| released = {{Start date and age|1985}}
| developer = Research Software Ltd
| designer = [[David Turner (computer scientist)|David Turner]]
| released = {{Start date and age|1985}}
| developer = Research Software Ltd
| latest release version =
| latest release date = <!-- {{start date and age|YYYYyyyy|MMmm|DDdd}} -->
| latest preview version =
| latest preview date = <!-- {{start date and age|YYYYyyyy|MMmm|DDdd}} -->
| typing = [[strongStrong and weak typing|strong]], [[staticStatic typing|static]]
| implementations = Miranda
| dialects =
| influenced by = [[Kent Recursive Calculator|KRC]], [[ML (programming language)|ML]], [[SASL (programming language)|SASL]], [[Hope (programming language)|Hope]]
| influenced = [[Clean (programming language)|Clean]], [[Haskell (programming language)|Haskell]], [[Orwell (programming language)|Orwell]], [[Microsoft Power Fx]]
| programming language =
| platform =
| operating system =
| license =
| website = {{URL|http://miranda.org.uk}}
| wikibooks =
}}
'''Miranda''' is a [[lazy evaluation|lazy]], [[functional programming|purely functional]] [[programming language]] designed by [[David Turner (computer scientist)|David Turner]] as a successor to his earlier programming languages [[SASL programming language|SASL]] and [[Kent Recursive Calculator|KRC]], using some concepts from [[ML (programming language)|ML]] and [[Hope (programming language)|Hope]]. It was produced by Research Software Ltd. of England (which holds a trademark on the name ''Miranda'')<ref>{{Cite journal|last=Turner|first=D. A.|date=1985|editor-last=Jouannaud|editor-first=Jean-Pierre|title=Miranda: A non-strict functional language with polymorphic types|url=https://link.springer.com/chapter/10.1007%2F3-540-15975-4_26|journal=Functional Programming Languages and Computer Architecture|series=Lecture Notes in Computer Science|volume=201 |language=en|___location=Berlin, Heidelberg|publisher=Springer|pages=1–16|doi=10.1007/3-540-15975-4_26|isbn=978-3-540-39677-2}}</ref> and was the first purely functional language to be commercially supported.{{citation needed|date=November 2016}}
 
Miranda was first released in 1985 as a fast interpreter in [[C (programming language)|C]] for [[Unix]]-flavour operating systems, with subsequent releases in 1987 and 1989. It had a strong influence on the later [[Haskell (programming language)|Haskell]] programming language.<ref>{{Cite journal|last1=Hudak|first1=Paul|last2=Hughes|first2=John|last3=Peyton Jones|first3=Simon|last4=Wadler|first4=Philip|date=2007-06-09|title=A history of Haskell: Being lazy with class|url=http://dx.doi.org/10.1145/1238844.1238856|journal=Proceedings of the Third ACM SIGPLAN Conference on History of Programming Languages|___location=New York, NY, USA|publisher=ACM|doi=10.1145/1238844.1238856|s2cid=52847907 }}</ref>
 
In 2020 a version of Miranda was released as open source under a [[BSD 2-Clause|BSD licence]]. The codebase has been updated to conform to modern C standards ([[C11 (C standard revision)|C11]]/[[C18 (C standard revision)|C18]]) and to generate 64-bit binaries. This has been tested on operating systems including [[Debian]], [[Ubuntu]], [[Windows Subsystem for Linux|WSL]]/Ubuntu, and [[MacOSmacOS]] ([[MacOSmacOS Catalina|Catalina]]).<ref>{{Cite web|last=Turner|first=David|date=2021-03-22|title=Open Sourcing Miranda|url=http://codesync.global/media/open-sourcing-miranda-david-turner-code-mesh-v-2020-codemeshv2020/|url-status=live|access-date=2021-12-30|website=Code Sync|language=en|publication-place=London|publication-date=November 2020}}</ref><ref>{{Cite web|title=Miranda download page|url=https://www.cs.kent.ac.uk/people/staff/dat/miranda/downloads/|url-status=live|access-date=2021-12-30|website=www.cs.kent.ac.uk}}</ref>
 
== Overview ==
Miranda is a [[lazy evaluation|lazy]], [[functional programming|purely functional]] programming language. That is, it lacks [[Side effect (computer science)|side effect]]s and [[imperative programming]] features. A Miranda program (called a ''script'') is a set of [[equation]]s that define various mathematical [[function (mathematics)|function]]s and [[algebraic data type]]s. The word ''[[setSet (mathematics)|set]]'' is important here: the order of the equations is, in general, irrelevant, and there is no need to define an entity prior to its use.
 
Since the [[parsing]] algorithm makes intelligent use of layout (indentation, via [[off-side rule|layout]] (indentation), therebracketing isstatements are rarely a need for bracketing statementsneeded and no statement terminators are requiredunneeded. This feature, inspired by [[ISWIM]], is also used in [[occam (programming language)|occam]] and [[Haskell (programming language)|Haskell]] and was later popularized by [[Python (programming language)|Python]].
 
[[Comment (computer programming)|Comment]]ary is introduced into regular scripts by the characters <code>||</code> and continue to the end of the same line. An alternative commenting convention affects an entire source code file, known as a "[[Literate programming|literate script]]", in which every line is considered a comment unless it starts with a <code>&gt;</code> sign.
Line 48:
</syntaxhighlight>
 
The ''[[listList (computingabstract data type)|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:
 
<syntaxhighlight lang="haskell">
Line 88:
The notation for function application is simply juxtaposition, as in <code>sin x</code>.
 
In Miranda, as in most other purely functional languages, functions are [[first-class function|first-class]] citizens, which is to say that they can be passed as [[parameter (computer science)|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 [[currying|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:
 
<syntaxhighlight lang="haskell">
Line 104:
</syntaxhighlight>
 
is the briefest way to create a function that adds one to its argument. Similarly, in
 
<syntaxhighlight lang="haskell">
Line 256:
isAvl (N l w r) = and (isAvl l) (isAvl r), if amount ((nodecount l) - (nodecount r)) < 2
= False, otherwise
 
 
 
 
delete :: * -> tree * -> tree *
delete x E = E