Miranda - A Functional Language
History
Miranda is a
functional programming language built for the
UNIX environment.
Developed between 1985 and 1986 by David Turner, Miranda was designed to produce a
commercial version of a
standard non-strict purely functional language. (Purists will note that it is pretty difficult to get a
purely functional language, see
referential transparency).
Uses
Miranda is an
archaic language, and in the shadow of the mighty
Haskell, has degenerated to a mere
teaching language. But, in its prime, it was used:
Structure
Miranda is composed of some fairly basic
data types:
num : Numbers, Miranda's basic number type is similar to the real number types in other languages.
char : Characters, single characters, such as 'A', 'a', '.' or '6'.
bool : Boolean, true or false.
Tuples : Sets of non-homogeneously typed values.
Lists : Sets of homogeneously typed values. Miranda can have lists of infinite length.
New types can be defined as follws:
string == [char]
(List of characters)
Functions are defined in this form:
FunctionName :: InputType1 -> InputType2 ->..-> InputTypeN -> OutputType
FunctionName Arg1 Arg2..ArgN = Statement
Notice functions can only EVER produce a single value as a result. However, this value can be a list. All functions in Miranda are curried (see: Currying Functions).
Example
Using
recursion:
>greenbottles :: num -> string
>greenbottles 0 = "no green bottles standing on the wall.\n"
>greenbottles (x+1) = show (x+1) ++ " green bottles standing on the wall.\n" ++
> show (x+1) ++ " green bottles standing on the wall,\n" ++
> "and if one green bottle, should accidentally fall,\n" ++
> "there'll be " ++ greenbottles x
Alternatives
A
PC friendly version of Miranda is available, called "
Amanda", and was developed by Dick Bruin.
For more info...
Information on Miranda is very hard to come by, as it is living in the shadows of the functional programming world. Haskell dominates, simply because it is more
powerful. Everything that can be done in Miranda can be done in Haskell. Haskell also has
Monads. However, because of it's limited functionality, Miranda
does make a good teaching langauge. Take it from me, I had to learn about functional programming through Miranda on my
University course.
Try here for some limited inforamtion about the Miranda language:http://www.engin.umd.umich.edu/CIS/course.des/cis400/miranda/miranda.html
Dick Bruin's homepage was last seen here:
http://www.engineering.tech.nhl.nl/engineering/personeel/bruin/