# Haskell programming language

Haskell is a standardized functional programming language with non-strict semantics, named after the logician Haskell Curry. It was created by a committee formed in the 1980s for the express purpose of defining such a language. 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, list comprehensions and guard statements. 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 a new method of 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).

 Contents

## Examples

The classic definition of the factorial function:

```fac 0 = 1
fac n = n * fac (n - 1)
```

The cute definition of the factorial function (using a built-in Haskell list notation and the standard `product` function):

```fac n = product [1..n]
```

A naïve implementation of a function which returns the nth number in the Fibonacci sequence:

```fib 0 = 0
fib 1 = 1
fib n = fib (n - 2) + fib (n - 1)
```

A function which returns a list of the Fibonacci numbers in linear time:

```fibs@(_:rest) = 0 : 1 : (zipWith (+) fibs rest)
```

The previous function creates an infinite list, which is possible because of lazy evaluation. One could implement `fib` as:

```fib n = fibs !! n
```

(`!!` is an operator which gets the nth element of a list).

The Quicksort algorithm can be elegantly expressed in Haskell with the help of list comprehensions:

```qsort [] = []
qsort (pivot:tail) =
qsort left ++ [pivot] ++ qsort right
where
left = [y | y <- tail, y < pivot]
right = [y | y <- tail, y >= pivot]
```

(Note that because of excessive copying and concatenation of lists this code can be rather slow, depending on the implementation.)

A remarkably concise function that returns the list of Hamming numbers in order:

```hamming = 1 : map (*2) hamming # map (*3) hamming # map (*5) hamming
where xxs@(x:xs) # yys@(y:ys)
| x==y = x : xs#ys
| x<y  = x : xs#yys
| x>y  = y : xxs#ys
```

## Implementations

The following all comply fully, or very nearly, with the Haskell 98 standard, and are distributed under open source licences. There are currently no commercial Haskell implementations.

• Hugs ([1] (http://www.haskell.org/hugs/)) is a bytecode interpreter. It offers fast compilation of programs and reasonable execution speed. It also comes with a simple graphics library. Hugs is good for people learning the basics of Haskell, but is by no means a "toy" implementation. It is the most portable and lightweight of the Haskell implementations.
• Glasgow Haskell Compiler ([2] (http://www.haskell.org/ghc/)). The Glasgow Haskell Compiler compiles to native code on a number of different architectures, and can also compile to C. GHC is probably the most popular Haskell compiler, and there are quite a few useful libraries (e.g. bindings to OpenGL) that will only work with GHC.
• nhc98 ([3] (http://www.cs.york.ac.uk/fp/nhc98/)) is another bytecode compiler, but the bytecode runs significantly faster than with Hugs. Nhc98 focuses on minimising memory usage, and is a particularly good choice for older, slower machines.
• HBC ([4] (http://www.cs.chalmers.se/~augustss/hbc/hbc.html)) is another native-code Haskell compiler. It hasn't been actively developed for some time, but is still usable.
• Helium ([5] (http://www.cs.uu.nl/helium/)) is a newer dialect of Haskell. The focus is on making it easy to learn. It currently lacks typeclasses, making it incompatible with many Haskell programs.

## External links

##### Navigation

Academic Kids Menu

• Art and Cultures
• Art (http://www.academickids.com/encyclopedia/index.php/Art)
• Architecture (http://www.academickids.com/encyclopedia/index.php/Architecture)
• Cultures (http://www.academickids.com/encyclopedia/index.php/Cultures)
• Music (http://www.academickids.com/encyclopedia/index.php/Music)
• Musical Instruments (http://academickids.com/encyclopedia/index.php/List_of_musical_instruments)
• Biographies (http://www.academickids.com/encyclopedia/index.php/Biographies)
• Clipart (http://www.academickids.com/encyclopedia/index.php/Clipart)
• Geography (http://www.academickids.com/encyclopedia/index.php/Geography)
• Countries of the World (http://www.academickids.com/encyclopedia/index.php/Countries)
• Maps (http://www.academickids.com/encyclopedia/index.php/Maps)
• Flags (http://www.academickids.com/encyclopedia/index.php/Flags)
• Continents (http://www.academickids.com/encyclopedia/index.php/Continents)
• History (http://www.academickids.com/encyclopedia/index.php/History)
• Ancient Civilizations (http://www.academickids.com/encyclopedia/index.php/Ancient_Civilizations)
• Industrial Revolution (http://www.academickids.com/encyclopedia/index.php/Industrial_Revolution)
• Middle Ages (http://www.academickids.com/encyclopedia/index.php/Middle_Ages)
• Prehistory (http://www.academickids.com/encyclopedia/index.php/Prehistory)
• Renaissance (http://www.academickids.com/encyclopedia/index.php/Renaissance)
• Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
• United States (http://www.academickids.com/encyclopedia/index.php/United_States)
• Wars (http://www.academickids.com/encyclopedia/index.php/Wars)
• World History (http://www.academickids.com/encyclopedia/index.php/History_of_the_world)
• Human Body (http://www.academickids.com/encyclopedia/index.php/Human_Body)
• Mathematics (http://www.academickids.com/encyclopedia/index.php/Mathematics)
• Reference (http://www.academickids.com/encyclopedia/index.php/Reference)
• Science (http://www.academickids.com/encyclopedia/index.php/Science)
• Animals (http://www.academickids.com/encyclopedia/index.php/Animals)
• Aviation (http://www.academickids.com/encyclopedia/index.php/Aviation)
• Dinosaurs (http://www.academickids.com/encyclopedia/index.php/Dinosaurs)
• Earth (http://www.academickids.com/encyclopedia/index.php/Earth)
• Inventions (http://www.academickids.com/encyclopedia/index.php/Inventions)
• Physical Science (http://www.academickids.com/encyclopedia/index.php/Physical_Science)
• Plants (http://www.academickids.com/encyclopedia/index.php/Plants)
• Scientists (http://www.academickids.com/encyclopedia/index.php/Scientists)
• Social Studies (http://www.academickids.com/encyclopedia/index.php/Social_Studies)
• Anthropology (http://www.academickids.com/encyclopedia/index.php/Anthropology)
• Economics (http://www.academickids.com/encyclopedia/index.php/Economics)
• Government (http://www.academickids.com/encyclopedia/index.php/Government)
• Religion (http://www.academickids.com/encyclopedia/index.php/Religion)
• Holidays (http://www.academickids.com/encyclopedia/index.php/Holidays)
• Space and Astronomy
• Solar System (http://www.academickids.com/encyclopedia/index.php/Solar_System)
• Planets (http://www.academickids.com/encyclopedia/index.php/Planets)
• Sports (http://www.academickids.com/encyclopedia/index.php/Sports)
• Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
• Weather (http://www.academickids.com/encyclopedia/index.php/Weather)
• US States (http://www.academickids.com/encyclopedia/index.php/US_States)

Information

• Home Page (http://academickids.com/encyclopedia/index.php)
• Contact Us (http://www.academickids.com/encyclopedia/index.php/Contactus)

• Clip Art (http://classroomclipart.com)