Edited by Graham Hutton, University of Nottingham
Version of November 2002
(This document is no longer being updated)
Comp.lang.functional is an unmoderated usenet newsgroup for the discussion of all aspects of functional programming languages, including their design, application, theoretical foundation, and implementation. Articles posted to this (and other) newsgroups are archived on the web at:
This document is a Frequently Asked Questions list (FAQ) for comp.lang.functional, and provides brief answers to a number of common questions concerning functional programming languages, and some pointers to relevant literature and internet resources. The latest version of this document is available on the web from:
Much of the information in this document has been taken from public sources, mostly from articles posted to comp.lang.functional. Because of the way that this document was compiled, a complete list of contributors is not available. Any opinions expressed in this document are those of the individual contributors, and may not be representative of views of the editor, or of others in the functional programming community. Every effort has been made to ensure that the content of this document is correct and up-to-date, but no guarantees are given for the accuracy of the information provided here. Your corrections and contributions are encouraged!
The original version of this Frequently Asked Questions list was compiled and edited by Mark P. Jones. All questions, comments, corrections, and suggestions regarding this document should be addressed to the current editor, Graham Hutton.
This section gives brief answers to a number of general questions concerning functional programming languages, and some pointers to relevant literature and internet resources.
What is a "functional programming language"?
Opinions differ, even within the functional programming community, on the precise definition of what constitutes a functional programming language. However, here is a definition that, broadly speaking, represents the kind of languages that are discussed in comp.lang.functional:
Functional programming is a style of programming that emphasizes the evaluation of expressions, rather than execution of commands. The expressions in these language are formed by using functions to combine basic values. A functional language is a language that supports and encourages programming in a functional style.
For example, consider the task of calculating the sum of the integers from 1
to 10. In an imperative language such as C, this might be expressed using
a simple loop, repeatedly updating the values held in an accumulator variable
total and a counter variable
total = 0; for (i=1; i<=10; ++i) total += i;
In a functional language, the same program would be expressed without any variable updates. For example, in Haskell, the result can be calculated by evaluating the expression:
[1..10] is an expression that represents the list of integers
from 1 to 10, while
sum is a function that can be used to calculate
the sum of an arbitrary list of values.
The same idea could also be used in (strict) functional languages such as SML or Scheme, but it is more common to find such programs written with an explicit loop, often expressed recursively. Nevertheless, there is still no need to update the values of the variables involved:
let fun sum i tot = if i=0 then tot else sum (i-1) (tot+i) in sum 10 0 end
(define sum (lambda (from total) (if (= 0 from) total (sum (- from 1) (+ total from))))) (sum 10 0)
It is often possible to write functional-style programs in an imperative language, and vice versa. It is then a matter of opinion whether a particular language can be described as functional or not.
Where can I find out more about the history and motivation for functional programming?
Here are two useful references:
Are there any textbooks about functional programming?
Yes, here are a selection:
Algorithms and data structures:
There are several other textbooks available, particularly in the programming and implementation categories. A comparison of a number of functional programming textbooks is made in the following article:
Are there any journals and conferences about functional programming?
Yes, here are a selection:
Most of these conferences have proceedings published by the ACM press, or in the Springer Verlag LNCS (Lecture Notes in Computer Science) series.
In addition to the above, Philip Wadler edits a column on functional programming for the Formal Aspects of Computer Science Newsletter, which is published by the British Computing Society Formal Aspects of Computing group and Formal Methods Europe.
Are there any schools and workshops on functional programming?
Yes, here are a selection:
Are functional programming languages useful in education?
Functional languages are gathering momentum in education because they facilitate the expression of concepts and structures at a high level of abstraction. Many university computing science departments now make use of functional programming in their undergraduate courses; indeed, a number of departments teach a functional language as their first programming language. Further information about the use of functional programming languages in education (including links to relevant conferences and workshops) is available on the web from:
This section gives brief answers to a number of technical questions concerning functional programming languages, and some pointers to relevant literature and internet resources.
What is a "purely functional" programming language?
This question has been the subject of some debate in the functional programming community. It is widely agreed that languages such as Haskell and Miranda are "purely functional", while SML and Scheme are not. However, there are some small differences of opinion about the precise technical motivation for this distinction. One definition that has been suggested is as follows:
The term "purely functional" is often used to describe languages that perform all their computations via function application. This is in contrast to languages, such as Scheme and Standard ML, that are predominantly functional but also allow `side effects' (computational effects caused by expression evaluation that persist after the evaluation is completed).See also:
Sometimes, the term "purely functional" is also used in a broader sense to mean languages that might incorporate computational effects, but without altering the notion of `function' (as evidenced by the fact that the essential properties of functions are preserved.) Typically, the evaluation of an expression can yield a `task', which is then executed separately to cause computational effects. The evaluation and execution phases are separated in such a way that the evaluation phase does not compromise the standard properties of expressions and functions. The input/output mechanisms of Haskell, for example, are of this kind.
What is "currying", and where does it come from?
Currying has its origins in the mathematical study of functions. It was observed by Frege in 1893 that it suffices to restrict attention to functions of a single argument. For example, for any two parameter function f(x,y), there is a one parameter function f' such that f'(x) is a function that can be applied to y to give (f'(x))(y) = f (x,y). This corresponds to the well known fact that the sets (AxB -> C) and (A -> (B -> C)) are isomorphic, where "x" is cartesian product and "->" is function space. In functional programming, function application is denoted by juxtaposition, and assumed to associate to the left, so that the equation above becomes f' x y = f(x,y).
Apparently, Frege did not pursue the idea further. It was rediscovered independently by Schoenfinkel, together with the result that all functions having to do with the structure of functions can be built up out of only two basic combinators, K and S. About a decade later, this sparked off the subject of combinatory logic, invented by Haskell Curry. The term "currying" honours him; the function f' in the example above is called the "curried" form of the function f. From a functional programming perspective, currying can be described by a function:
curry : ((a,b) -> c) -> (a -> b -> c)
The inverse operation is, unsurprisingly, refered to as uncurrying:
uncurry : (a -> b -> c) -> ((a,b) -> c)
For further reading, see:
What is a "monad", and what are they used for?
The concept of a monad comes from category theory; full details can be found in any standard textbook on the subject. Much of the interest in monads in functional programming is the result of recent papers that show how monads can be used to describe all kinds of different programming language features (for example, I/O, manipulation of state, continuations and exceptions) in purely functional languages such as Haskell:
How can I write a "parser" in a functional programming language?
A parser is a program that converts a list of input tokens, usually characters, into a value of the appropriate type. A simple example might be a function to find the integer value represented by a string of digits. A more complex example might be to translate programs written in a particular concrete syntax into a suitable abstract syntax as the first stage in the implementation of a compiler or interpreter. There are two common ways to write a parser in a functional language:
Host: ftp.diku.dk; Directory: /pub/diku/dists.
Host: ftp.research.bell-labs.com; Directory: /dist/smlnj.
What does it mean to say that a functional programming language is "strict" or "non-strict"?
Here's one (operational) way to explain the difference:
There is much debate in the functional programming community about the relative merits of strict and non-strict languages. It is possible, however, to support a mixture of these two approaches; for example, some versions of the functional language Hope do this.
What is the performance of functional programs like?
In some circles, programs written in functional languages have obtained a reputation for lack of performance. Part of this results from the high-level of abstraction that is common in such programs and from powerful features such as higher-order functions, automatic storage management, etc. Of course, the performance of interpreters and compilers for functional languages keeps improving with new technological developments.
Here are a selection of references for further reading:
Host: ftp.fwi.uva.nl; Directory: pub/functional/reports.
Where can I find out about applications of functional programming?
Here are a selection of places to look:
Further details are available on the web from:
This section gives some pointers to other internet resources on functional programming.
Host: ftp.dcs.warwick.ac.uk; Directory: /pub/biblio.
Host: tamdhu.dcs.st-and.ac.uk; Directory: /pub/staple.
Host: nebula.cs.yale.edu; Directory: /pub/yale-fp/papers.
This section gives a brief overview of a number of programming languages that support aspects of the functional paradigm, and some pointers to relevant literature and internet resources. The table below classifies the languages into strict/non-strict and sequential/concurrent, and may be useful when searching for suitable languages for particular applications. Some of the languages have multiple versions with different classifications (see the language overviews for further details), but for simplicity only the most common version of each language is considered in the table.
Sequential: Concurrent: Strict: ASpecT
ASpecT is a strict functional language, developed at the University of Bremen, originally intended as an attempt to provide an implementation for (a subset of) Algebraic Specifications of Abstract Datatypes. The system was designed to be as user-friendly as possible, including overloading facilities and a source-level debugger. For reasons of efficiency, the system uses call-by-value evaluation and reference counting memory management.
Over the years more and more features have been added, including subsorting, functionals, and restricted polymorphism. The ASpecT compiler translates the functional source code to C, resulting in fast and efficient binaries. ASpecT has been ported to many different platforms, including Sun3, Sun4, Dec VAX, IBM RS6000, NeXT, Apple A/UX, PC (OS/2, Linux), Amiga and Atari ST/TT. The ASpecT compiler is available by ftp from:
Host: ftp.Uni-Bremen.DE; Directory: /pub/programming/languages/ASpecT.
The most important application of ASpecT to date is the interactive graph visualization system daVinci; currently (September '96), version 2.0.x is composed of 34.000 lines of ASpecT code, 12.000 lines of C code and 8000 lines of Tcl/Tk code. daVinci is an X11 program, and is available for UNIX workstations from Sun, HP, IBM, DEC, SGI, and for Intel PCs with a UNIX operating system. Further information about daVinci is available on the web from:
Caml is a dialect of the ML language developed at INRIA that does not comply to the Standard, but actually tries to go beyond the Standard, in particular in the areas of separate compilation, modules, and objects. Two implementations of Caml are available:
Objective Caml is available for Unix and Windows 95/NT, with the native-code compiler supporting the following processors: Alpha, Sparc, Pentium, Mips, Power, HPPA.
Both implementations of Caml are available by ftp from:
Host: ftp.inria.fr; Directory: /lang/caml-light.
Further information about Caml is available on the web from:
The Concurrent Clean system is a programming environment for the functional language Concurrent Clean, developed at the University of Nijmegen in The Netherlands. The system is one of the fastest implementations of functional languages available at the time of writing. Through the use of uniqueness typing, it is possible to write purely functional interactive programs, including windows, menus, dialogs, etc. It is also possible to develop real-life applications that interface with non-functional systems. With version 1.0, the language emerged from an intermediate language to a proper programming language. Features provided by the language include:
Concurrent Clean is available for PCs (Microsoft Windows, Linux), Macintoshes (Motorola, PowerPC), and Sun4s (Solaris, SunOS). The system is available by ftp from:
Host: ftp.cs.kun.nl; Directory: /pub/Clean.
Further information about Concurrent Clean is available on the web from:
A book describing the background and implementation of Concurrent Clean is also available:
Erlang is a dynamically typed concurrent functional programming language for large industrial real-time systems. Features of Erlang include:
Erlang is freely available on the web from:
Erlang is distributed together with full source code for a number of applications, including:
FP is a side-effect free, combinator style language, described in:
A interpreter and a compiler (to C) for FP are available by ftp from:
Host: gatekeeper.dec.com; Directory: pub/usenet/comp.sources.unix/volume13/funcproglang; Directory: pub/usenet/comp.sources.unix/volume20/fpc.
The Illinois FP system supports a modified version of FP that has a more Algol-like syntax and structure, and is described in the following article:
The Gofer system provides an interpreter for a small language based closely on the current version of the Haskell report. In particular, Gofer supports lazy evaluation, higher-order functions, polymorphic typing, pattern-matching, support for overloading, etc.
The most recent version of Gofer, 2.30a, is available by ftp from:
Host: ftp.cs.nott.ac.uk; Directory: /nott-fp/languages/gofer.
Gofer runs on a wide range of machines including PCs, Ataris, Amigas, etc. as well as larger Unix-based systems. A version for the Apple Macintosh is also available, by ftp from:
Host: ftp.dcs.glasgow.ac.uk; Directory: /pub/haskell/gofer/macgofer.
Please note the spelling of Gofer, derived from the notion that functional languages are GO(od) F(or) E(quational) R(easoning). This is not to be confused with `Gopher', the widely used internet distributed information delivery system.
In the mid-1980s, there was no "standard" non-strict, purely-functional programming language. A language-design committee was set up in 1987, and the Haskell language is the result. At the time of writing, Haskell 98 is the latest version of the language. Further information about Haskell, including the latest version of the Haskell report, is available on the web from:
At the time of writing, there are three different Haskell systems available, developed by groups at Chalmers, Glasgow and Yale. These systems are available by ftp from the following sites:
Host: ftp.cs.chalmers.se; Directory: /pub/haskell.
Host: ftp.dcs.glasgow.ac.uk; Directory: /pub/haskell.
Host: haskell.cs.yale.edu; Directory: /pub/haskell.
Host: ftp.cs.nott.ac.uk; Directory: /haskell.
Host: src.doc.ic.ac.uk; Directory: /pub/computing/programming/languages/haskell.
You can join the Haskell mailing list by emailing email@example.com, with a message body of the form: subscribe haskell Forename Surname <email@address>.
Hope is a small polymorphically-typed functional language, and was the first language to use call-by-pattern. Hope was originally strict, but there are versions with lazy lists, or with lazy constructors but strict functions. Further information is available on the web from:
Hugs, the Haskell User's Gofer System, is an interpreted implementation of Haskell with an interactive development environment much like that of Gofer. Further information about Hugs is available on the web from:
Id is a dataflow programming language, whose core is a non-strict functional language with implicit parallelism. It has the usual features of many modern functional programming languages, including a Hindley/Milner type inference system, algebraic types and definitions with clauses and pattern matching, and list comprehensions.
J was designed and developed by Ken Iverson and Roger Hui. It is similar to the language APL, departing from APL in using using the ASCII alphabet exclusively, but employing a spelling scheme that retains the advantages of the special alphabet required by APL. It has added features and control structures that extend its power beyond standard APL. Although it can be used as a conventional procedural programming language, it can also be used as a pure functional programming language. Further information about J is available on the web from:
Miranda was designed in 1985-6 by David Turner with the aim of providing a standard non-strict purely functional language, and is described in the following articles:
Miranda was the first widely disseminated language with non-strict semantics and polymorphic strong typing, and is running at over 600 sites, including 250 universities. It is widely used for teaching, often in conjunction with "Introduction to Functional Programming", by Bird and Wadler, which uses a notation closely based on Miranda. It has also had a strong influence on the subsequent development of the field, and provided one of the main inputs for the design of Haskell.
The Miranda™ system is a commercial product of Research Software Limited. Miranda release two (the current version at the time of writing) supports unbounded precision integers and has a module system with provision for parameterized modules and a built in "make" facility. The compiler works in conjunction with a screen editor and programs are automatically recompiled after edits. There is also an online reference manual.
Further information about Miranda is available on the web from:
Miranda is not in the public domain but is free for personal and educational use.
Mercury is a logic/functional programming language, which combines the clarity and expressiveness of declarative programming with advanced static analysis and error detection facilities. It has a strong type system, a module system (allowing separate compilation), a mode system, algebraic data types, parametric polymorphism, support for higher-order programming, and a determinism system --- all of which are aimed at both reducing programming errors and providing useful information for programmers and compilers.
The Mercury compiler is written in Mercury itself, and compiles to C. The compiler is available for a variety of platforms running Unix and Microsoft operating systems.
Further information about Mercury is available on the web from:
ML stands for meta-language, and is a family of advanced programming languages with (usually) functional control structures, strict semantics, a strict polymorphic type system, and parameterized modules. It includes Standard ML, Lazy ML, CAML, CAML Light, and various research languages. Implementations are available on many platforms, including PCs, mainframes, most models of workstation, multi-processors and supercomputers. ML has many thousands of users, and is taught to undergraduates at many universities.
There is a moderated usenet newsgroup, comp.lang.ml, for discussion of topics related to ML. A list of frequently asked questions for this newsgroup (which includes pointers to many of the different implementations and variants of ML) is available by ftp from:
Host: pop.cs.cmu.edu; Directory: /usr/rowan/sml-archive/.
The Standard ML language is formally defined by:
Further information is available on the web from:
There is now a revised version of Standard ML, sometimes referred to as "Standard ML '97" to distinguish it from the original 1990 version. The new version combines modest changes in the language with a major revision and expansion of the SML Basis Library. Further details about Standard ML '97 are available on the web from:
NESL is a fine-grained, functional, nested data-parallel language, loosly based on ML. It includes a built-in parallel data-type, sequences, and parallel operations on sequences (the element type of a sequence can be any type, not just scalars). It is based on eager evaluation, and supports polymorphism, type inference and a limited use of higher-order functions. Currently, it does not have support for modules and its datatype definition is limited. Except for I/O and some system utilities it is purely functional (it does not support reference cells or call/cc).
The NESL compiler is based on delayed compilation and compiles separate code for each type a function is used with (compiled code is monomorphic). The implementation therefore requires no type bits, and can do some important data-layout optimizations (for example, double-precision floats do not need to be boxed, and nested sequences can be laid out efficiently across multiple processors.) For several small benchmark applications on irregular and/or dynamic data (for example, graphs and sparse matrices) it generates code comparable in efficiency to machine-specific low-level code (for example, Fortran or C.)
The current implementation of NESL runs on workstations, the Connection Machines CM2 and CM5, the Cray Y-MP and the MasPar MP2.
Further information about NESL is available on the web from:
or by ftp from:
Host: nesl.scandal.cs.cmu.edu; Directory: nesl.
You can join to the NESL mailing list by emailing firstname.lastname@example.org.
The language OPAL has been designed as a testbed for the development of functional programs. Opal molds concepts from Algebraic Specification and Functional Programming, which shall favor the formal development of large production-quality software that is written in a purely functional style. The core of OPAL is a strongly typed, higher-order, strict applicative language that belongs to the tradition of Hope and ML. The algebraic flavour of OPAL shows up in the syntactical appearance and in the preference of parameterization to polymorphism.
OPAL is used for research on the highly optimizing compilation of applicative languages. This has resulted in a compiler which produces very efficient code. The OPAL compiler itself is entirely written in OPAL. Installation is straightforward and has been successfully performed for SPARCs, DECstations, NeXTs, and PCs running LINUX.
Further information about OPAL is available by ftp from:
Host: ftp.cs.tu-berlin.de; Directory: /pub/local/uebb/.
Oz is a concurrent constraint programming language designed for applications that require complex symbolic computations, organization into multiple agents, and soft real-time control. It is based on a new computation model providing a uniform foundation for higher-order functional programming, constraint logic programming, and concurrent objects with multiple inheritance. From functional languages Oz inherits full compositionality, and from logic languages Oz inherits logic variables and constraints (including feature and finite domain constraints.) Search in Oz is encapsulated (no backtracking) and includes one, best and all solution strategies.
DFKI Oz is an interactive implementation of Oz featuring am Emacs programming interface, a concurrent browser, an object-oriented interface to Tcl/Tk, powerful interoperability features (sockets, C, C++), an incremental compiler, a garbage collector, and support for stand-alone applications. Performance is competitive with commercial Prolog and Lisp systems. DFKI Oz is available for many platforms running Unix/X, including Sparcs and 486 PCs, and has been used for applications including simulations, multi-agent systems, natural language processing, virtual reality, graphical user interfaces, scheduling, placement problems, and configuration.
Further information about Oz is available on the web from:
or by ftp from:
Host: ftp.ps.uni-sb.de; Directory: /pub/oz.
Specific questions on Oz may be emailed email@example.com. You can join the Oz users mailing list by emailing firstname.lastname@example.org.
Pizza is a strict superset of Java that incorporates three ideas from functional programming:
Pizza is defined by translation into Java and compiles into the Java Virtual Machine, requirements which strongly constrain the design space. Thus Pizza programs interface easily with Java libraries, and programs first developed in Pizza may be automatically converted to Java for ease of maintenance. The Pizza compiler is itself written in Pizza, and may be used as a replacement for Sun's Java compiler (except that the Pizza compiler runs faster).
Pizza was designed by Martin Odersky and Philip Wadler, and implemented by Odersky. The design is described in the following paper:
The paper, downloads, and other information on Pizza is available on the web from any of the following locations (which mirror each other):
Pizza has received a `cool' award from Gamelan ( http://www-c.gamelan.com/.)
Scheme is a dialect of Lisp that stresses conceptual elegance and simplicity. It is specified in R4RS and IEEE standard P1178. Scheme is much smaller than Common Lisp; the specification is about 50 pages. Scheme is often used in computer science curricula and programming language research, due to its ability to simply represent many programming abstractions.
Further information about Scheme is available on the web from:
There is an unmoderated usenet newsgroup, comp.lang.scheme, for the discussion of topics related to Scheme. A list of frequently asked questions (which includes details of the many books and papers concerned with Scheme) for this newsgroup is available by ftp from:
Host: ftp.think.com; Directory: /public/think/lisp/.
Sisal (Streams and Iteration in a Single Assignment Language) is a functional language designed with several goals in mind: to support clear, efficient expression of scientific programs; to free application programmers from details irrelevant to their endeavors; and, to allow automatic detection and exploitation of the parallelism expressed in source programs.
Sisal syntax is modern and easy to read; Sisal code looks similar to Pascal, Modula, or Ada, with modern constructs and long identifiers. The major difference between Sisal and more conventional languages is that it does not express explicit program control flow.
Sisal semantics are mathematically sound. Programs consist of function definitions and invocations. Functions have no side effects, taking as inputs only explicitly passed arguments, and producing only explicitly returned results. There is no concept of state in Sisal. Identifiers are used, rather than variables, to denote values, rather than memory locations.
The Sisal language currently exists for several shared memory and vector systems that run Berkeley Unix(tm), including the Sequent Balance and Symmetry, the Alliant, the Cray X/MP and Y/MP, Cray 2, and a few other less well-known ones. Sisal is available on sequential machines such as Sparc, RS/6000, and HP. Sisal also runs under MS-DOS and Macintosh Unix (A/UX). It's been shown to be fairly easy to port the entire language system to new machines.
Further information about Sisal is available on the web from:
The original version of this Frequently Asked Questions list (FAQ) was compiled and edited by Mark P. Jones. All questions, comments, corrections, and suggestions regarding this document should be addressed to the current editor, Graham Hutton.