AardvarkBusiness.net - Business Search Engine AardvarkBusiness.net - Business Search Engine


Home > Programming

Haskell Programming Language
by Wikipedia of Wikipedia.org
 
Wikipedia is a free content encyclopedia written collaboratively by contributors from around the world.
Click here to see other articles by Wikipedia
 
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).

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 naive 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.)

This article is licensed under the GNU Free Documentation License.
It uses material from the Wikipedia article "Haskell programming language".
 
Email this article to a friend
HTML code (to link to this article from your Website)
BBCode (to link to this article in a forum post)

   

Latest Articles

° The Top Twelve E-Mail Mistakes...
° IEEE 802.17
° WiMAX
° IEEE 802.6
° IEEE 802.3
° Logical link control (LLC)
° IEEE 802.1
° Systems Network Architecture
° Open systems interconnect
° IPX/SPX

Aardvark Articles Search Engine - Aardvark Articles Directory - Aardvark Articles Forum - Add Your Articles
Make Aardvark Articles your homepage - Bookmark Aardvark Articles - Link to Aardvark Articles
Monitor your traffic with Aardvark Tracking


[Valid RSS]

Contact Aaron the Aardvark


© Website design by The Dedicated Partnership All rights reserved.