In the 1980s, a committee was formed to create a standardized functional programming language with non-strict semantics. Haskell, named after the logician Haskell Curry, was the result of those deliberations. The latest semi-official language standard is Haskell 98, intended to specify a minimal, portable version of the language for teaching and as a base for future extensions. The language continues to evolve rapidly, with Hugs and GHC (see below) representing the current de facto standard.
Interesting Haskell features include support for recursive functions and datatypes, pattern matching and list comprehensions. The combination of such features can make functions which would be difficult to write in a procedural programming language almost trivial to implement in Haskell. The language is, as of 2002, the functional language on which the most research is being performed. Several variants have been developed: parallelizable versions from MIT and Glasgow, both called Parallel Haskell, more parallel and distributed versions called Distributed Haskell (formerly Goffin) and Eden, a speculatively evaluating version called Eager Haskell and several object oriented versions: Haskell++, O'Haskell and Mondrian.
There is also a Haskell-like language that offers support for GUI development called Concurrent Clean. Its biggest deviation from Haskell is in the use of Uniqueness types for input as opposed to Monads.
An educational version of Haskell called Gofer was developed by Mark Jones. It was supplanted by HUGS, the Haskell User's Gofer System (see the implementations section of this article).
For more comprehensive information, see the haskell.org website, linked at the end of this article.
Table of contents |
2 Implementations 3 External links |
The cute definition of the factorial function (using a built-in Haskell list notation and the standard
A naive implementation of a function which returns the nth number in the Fibonacci sequence:
A function which returns a list of the Fibonacci numbers in linear time:
The previous function creates an infinite list, which is possible because of lazy evaluation.
One could implement
The Quicksort alogrithm can be elegantly expressed in Haskell with the help of list comprehensions:
Examples
The classic definition of the factorial function:
fac 0 = 1
fac n = n * fac (n - 1)
product
function):
fac n = product [1..n]
fib 0 = 0
fib 1 = 1
fib n = fib (n - 2) + fib (n - 1)
fibs = 0 : 1 : (zipWith (+) fibs (tail fibs))
fib
as:
fib n = fibs !! n
(!!
is an operator which gets the nth element of a list).
qsort [] = []
(Note that because of excessive copying and concatenation of lists this code can be rather slow, depending on the implementation.)
qsort (x:xs) =
qsort elts_lt_x ++ [x] ++ qsort elts_greq_x
where
elts_lt_x = [y | y <- xs, y < x]
elts_greq_x = [y | y <- xs, y >= x]
Implementations
The following all comply (or very nearly comply) with the Haskell 98 standard, and are distributed under open source licences. There are currently no commercial Haskell implementations.
External links