FACTOID # 56: In 1919, Kenya became the first African colony to give women the right to vote.
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
WHAT'S NEW
RECENT ARTICLES
More Recent Articles »
 

Encyclopedia > Haskell (programming language)
Haskell
Image:Haskell Logo.jpg
Paradigm: functional, non-strict, modular
Appeared in: 1990
Designed by: Simon Peyton-Jones, Paul Hudak[3], Philip Wadler, et al
Typing discipline: static, strong, inferred
Major implementations: GHC, Hugs, NHC, JHC, Yhc
Dialects: Helium
Influenced by: Miranda, ML, Gofer

Haskell is a standardized purely functional programming language with non-strict semantics, named after the logician Haskell Curry. It is one of the more popular functional languages, and the lazy functional language on which the most research is being performed.[1] Image File history File links Haskell logo. ... A programming paradigm is a paradigmatic style of programming (compare with a methodology, which is a paradigmatic style of doing software engineering). ... Functional programming is a programming paradigm that conceives computation as the evaluation of mathematical functions and avoids state and mutable data. ... Simon Peyton Jones is a British computer scientist who does research on the implementation and applications of functional programming languages, particularly lazy functional languages. ... Philip Wadler is a computer scientist well-known for his contributions to programming language design and type theory. ... In computer science, a type system defines how a programming language classifies values and expressions into types, how it can manipulate those types and how they interact. ... On computer science, a datatype (often simply type) is a name or label for a set of values and some operations which can be performed on that set of values. ... In computing, strongly-typed, when applied to a programming language, is used to describe how the language handles datatypes. ... Type inference is a feature present in some strongly statically typed programming languages. ... Look up Implementation in Wiktionary, the free dictionary. ... The Glasgow Haskell Compiler (or GHC) is an open source Native code Compiler for the functional programming language Haskell which was developed at the University of Glasgow. ... Hugs (Haskell Users Gofer System) (also Hugs 98) is a bytecode interpreter for the functional programming language Haskell. ... The York Haskell Compiler (or Yhc) is an open source bytecode compiler for the functional programming language Haskell; it primarily targets the Haskell 98 standard. ... A dialect of a programming language is a (relatively small) variation or extension of the language that does not change its intrinsic nature. ... Helium is a compiler and a dialect of the functional programming language Haskell. ... Miranda is a non-strict purely functional programming language developed by Professor David Turner as a successor to his earlier programming languages SASL and KRC, using some concepts from ML and Hope. ... ML is a general-purpose functional programming language developed by Robin Milner and others in the late 1970s at the University of Edinburgh, whose syntax is inspired by ISWIM. Historically, ML stands for metalanguage as it was conceived to develop proof tactics in the LCF theorem prover (the language of... Hugs (Haskell Users Gofer System) (also Hugs 98) is a bytecode interpreter for the functional programming language Haskell. ... Purely functional is a term in computing used to describe algorithms, data structures or programming languages that exclude destructive modifications (updates). ... A programming language is an artificial language that can be used to control the behavior of a machine, particularly a computer. ... A strict programming language is one in which only strict functions may be defined by the user. ... A logician is a philosopher, mathematician, or other whose topic of scholarly study is logic. ... Haskell Brooks Curry (September 12, 1900, Millis, Massachusetts - September 1, 1982, State College, Pennsylvania) was an American mathematician and logician. ... Functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions. ... In computer programming, lazy evaluation is a technique that attempts to delay computation of expressions until the results of the computation are known to be needed. ...

Contents

History

Following the publication of Miranda, in 1985, functional languages proliferated. By 1987, there existed more than a dozen competing non-strict, purely-functional programming languages. At the conference on Functional Programming Languages and Computer Architecture (FPCA '87) in Portland, Oregon, a meeting was held during which strong consensus was found among the participants that a committee should be formed to define an open standard for such languages. This would have the express purpose of consolidating the existing languages into a common one that would serve as a basis for future research in language design.[2] The first version of Haskell ("Haskell 1.0") was defined in 1990.[3] The committee's efforts resulted in a series of language definitions, which in late 1997, culminated in Haskell 98, intended to specify a stable, minimal, portable version of the language and an accompanying standard library for teaching, and as a base for future extensions. The committee expressly welcomed the creation of extensions and variants of Haskell 98 via adding and incorporating experimental features. Miranda is a non-strict purely functional programming language developed by Professor David Turner as a successor to his earlier programming languages SASL and KRC, using some concepts from ML and Hope. ... This article or section cites very few or no references or sources. ... Illustration of an application which may use libvorbisfile. ...


In January 1999, the Haskell 98 language standard was originally published as "The Haskell 98 Report". In January 2003, a revised version was published as "Haskell 98 Language and Libraries: The Revised Report".[4] The language continues to evolve rapidly, with the Hugs and GHC implementation (see below) representing the current de facto standard. In early 2006, the process of defining a successor to the Haskell 98 standard, informally named Haskell′ ("Haskell Prime"), was begun.[5] This process is intended to produce a minor revision of Haskell 98.[6] Hugs (Haskell Users Gofer System) (also Hugs 98) is a bytecode interpreter for the functional programming language Haskell. ... The Glasgow Haskell Compiler (or GHC) is an open source Native code Compiler for the functional programming language Haskell which was developed at the University of Glasgow. ...


Features and extensions

Characteristic features of Haskell include pattern matching, currying, list comprehensions [7], guards, definable operators, and single assignment. The language also supports recursive functions and algebraic data types, as well as lazy evaluation. Unique concepts include monads, and type classes. 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. Pattern matching is the act of checking for the presence of the constituents of a given pattern. ... In mathematics, computer science and linguistics (semantics), currying or Schönfinkelisation[1] is the technique of transforming a function that takes multiple arguments into a function that takes a single argument (the other arguments having been specified by the curry). ... In some programming languages, list comprehension is a syntactic construct for creating a list based on existing lists, analogous to the set-builder notation (set comprehension), that is, the mathematical notation such as the following: For an example, in Haskells list comprehension syntax, the example set-builder construct above... In computer programming, a guard is a boolean expression that must evaluate to true if the program execution is to continue in the branch in question. ... Programming languages generally have a set of operators that are similar to operators in mathematics: they are somehow special functions. ... Single assignment is used to describe a programming language or representation in which one can bind a value to a name at most once. ... A visual form of recursion known as the Droste effect. ... An algebraic data type is a datatype whose each value is data from other datatypes wrapped in one of the constructors of the datatype. ... In computer programming, lazy evaluation is a technique that attempts to delay computation of expressions until the results of the computation are known to be needed. ... Wikibooks Haskell has a page on the topic of Understanding monads Some functional programming languages make use of monads[1] [2] to structure programs which include operations that must be executed in a specific order. ... The type system of the Haskell programming language includes a construct called the type class that provides a powerful form of restricted parametric polymorphism. ... In computer science, a subroutine (function, procedure, or subprogram) is a sequence of code which performs a specific task, as part of a larger program, and is grouped as one, or more, statement blocks; such code is sometimes collected into software libraries. ... ...


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. The Massachusetts Institute of Technology (MIT) is a private, coeducational research university located in Cambridge, Massachusetts. ... The University of Glasgow is the largest of the three universities in Glasgow, Scotland. ... In computer science, speculative execution is the execution of code whose result may not actually be needed. ... Eager Haskell is an implementation of the Haskell programming language that uses eager evaluation. ... Object-oriented programming (OOP) is a computer programming paradigm in which a software system is modeled as a set of objects that interact with each other. ... OHaskell is an object-oriented, concurrent extension of the functional programming language Haskell. ... The Mondrian programming language is a scripting language developed by Utrecht University for use with Internet applications. ...


There is also a Haskell-like language that offers a new method of support for GUI development called Concurrent Clean. Its biggest deviations from Haskell are use of uniqueness types for input instead of monads. GUI can refer to the following: GUI is short for graphical user interface, a term used to describe a type of interface in computing. ... Clean is a purely functional programming language that, in some respects, is similar to the better-known Haskell programming language. ... In computing, a unique type guarantees that an object is used in a single-threaded way, without duplicating references to it. ... Wikibooks Haskell has a page on the topic of Understanding monads Some functional programming languages make use of monads[1] [2] to structure programs which include operations that must be executed in a specific order. ...


Applications

Although Haskell has a comparatively small user community, its strengths have been well applied to a few projects. Audrey Tang's Pugs is an implementation for the forthcoming Perl 6 language with an interpreter and compilers that proved useful already after just a few months of its writing; similarly, GHC is often a testbed for advanced functional programming features and optimizations. Darcs is a revision control system, with several innovative features. Linspire GNU/Linux chose Haskell for system tools development.[8] Xmonad is a window manager for the X Window System, written entirely in Haskell. This article is being considered for deletion in accordance with Wikipedias deletion policy. ... Pugs is a compiler and interpreter for the Perl 6 programming language, started on February 1, 2005 by Audrey Tang. ... Perl 6 is a planned major revision to the Perl programming language. ... Darcs is a distributed revision control system by David Roundy designed to replace the centralized CVS. Several noticeable differences in the design aim for simple use and powerful features. ... This article or section does not cite its references or sources. ... This article is being considered for deletion in accordance with Wikipedias deletion policy. ... A window manager is a general term for any software that controls the placement and appearance of windows on the screen, providing a top-level for a windowing system. ... KDE 3. ...


Examples

A simple example that is often used to demonstrate the syntax of functional languages is the factorial function, shown in Haskell: Functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions. ... For factorial rings in mathematics, see unique factorisation domain. ...

 fac :: Integer -> Integer fac 0 = 1 fac n | n > 0 = n * fac (n-1) 

Or in one line:

 fac n = if n > 0 then n * fac (n-1) else 1 

This describes the factorial as a recursive function, with one terminating base case. It is similar to the descriptions of factorials found in mathematics textbooks. Much of Haskell code is similar to standard mathematical notation in facility and syntax.


The first line of the factorial function shown is optional, and describes the types of this function. It can be read as the function fac (fac) has type (::) from integer to integer (Integer -> Integer). That is, it takes an integer as an argument, and returns another integer. The type of a definition is inferred automatically if the programmer didn't supply a type annotation.


The second line relies on pattern matching, an important feature of Haskell. Note that parameters of a function are not in parentheses but separated by spaces. When the function's argument is 0 (zero) it will return the integer 1 (one). For all other cases the third line is tried. This is the recursion, and executes the function again until the base case is reached. Pattern matching is the act of checking for the presence of the constituents of a given pattern. ... A visual form of recursion known as the Droste effect. ...


A guard protects the third line from negative numbers for which a factorial is undefined. Without the guard this function would recurse through all negative numbers without ever reaching the base case of 0. As it is, the pattern matching is not complete: if a negative integer is passed to the fac function as an argument, the program will fail with a runtime error. A final case could check for this error condition and print an appropriate error message instead. In computer programming, a guard is a boolean expression that must evaluate to true if the program execution is to continue in the branch in question. ...


The "Prelude" is a number of small functions analogous to C's standard library. Using the Prelude and writing in the point-free style of unspecified arguments, it becomes: C is a general-purpose, procedural, imperative computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system. ... The C standard library is a now-standardised collection of header files and library routines used to implement common operations, such as input/output and string handling, in the C programming language. ... Function-level programming refers to one of the two contrasting programming paradigms identified by John Backus in his work on Programs as mathematical objects, the other being Value-level programming. ...

 fac = product . enumFromTo 1 

The above is close to mathematical definitions such as f = g o h (see function composition), and indeed, it is not an assignment of a value to a variable. In mathematics, a composite function, formed by the composition of one function on another, represents the application of the former to the result of the application of the latter to the argument of the composite. ...


In the Hugs interpreter, you often need to define the function and use it on the same line separated by a where or let..in, meaning you need to enter this to test the above examples and see the output 120:

 let { fac 0 = 1; fac n | n > 0 = n * fac (n-1) } in fac 5 

or

 fac 5 where fac = product . enumFromTo 1 

The GHCi interpreter doesn't have this restriction and function definitions can be on one line to be used later.


More complex examples

A simple RPN calculator expressed with the higher-order function foldl whose argument f is defined in a where clause using pattern matching and the type class Read: Postfix notation is a mathematical notation wherein every operator follows all of its operands. ... In mathematics and computer science, higher-order functions are functions which can take other functions as arguments, and may also return functions as results. ... In functional programming, fold or reduce or accumulate is a family of higher-order functions that process a data structure in some order and build up a return value. ... Pattern matching is the act of checking for the presence of the constituents of a given pattern. ... The type system of the Haskell programming language includes a construct called the type class that provides a powerful form of restricted parametric polymorphism. ...

 calc :: String -> [Float] calc = foldl f [] . words where f (x:y:zs) "+" = y+x:zs f (x:y:zs) "-" = y-x:zs f (x:y:zs) "*" = y*x:zs f (x:y:zs) "/" = y/x:zs f xs y = read y : xs 

The empty list is the initial state, and f interprets one word at a time, either matching two numbers from the head of the list and pushing the result back in, or parsing the word as a floating-point number and prepending it to the list. An interpreter is a computer program that executes other programs. ... A floating-point number is a digital representation for a number in a certain subset of the rational numbers, and is often used to approximate an arbitrary real number on a computer. ...


The following definition produces the list of Fibonacci numbers in linear time: In mathematics, the Fibonacci numbers form a sequence defined recursively by: In words: you start with 0 and 1, and then produce the next Fibonacci number by adding the two previous Fibonacci numbers. ...

 fibs = 0 : 1 : zipWith (+) fibs (tail fibs) 

The infinite list is produced by corecursion — the latter values of the list are computed on demand starting from the initial two items 0 and 1. This kind of a definition is an instance of lazy evaluation and an important part of Haskell programming. For an example of how the evaluation evolves, the following illustrates the values of fibs and tail fibs after the computation of six items and shows how zipWith (+) has produced four items and proceeds to produce the next item: In mathematics and computer science, recursion is a particular way of specifying (or constructing) a class of objects (or an object from a certain class) with the help of a reference to other objects of the class: a recursive definition defines objects in terms of the already defined objects of... In computer programming, lazy evaluation is a technique that attempts to delay computation of expressions until the results of the computation are known to be needed. ...

 fibs = 0 : 1 : 1 : 2 : 3 : 5 : ... + + + + + + tail fibs = 1 : 1 : 2 : 3 : 5 : ... = = = = = = zipWith ... = 1 : 2 : 3 : 5 : 8 : ... fibs = 0 : 1 : 1 : 2 : 3 : 5 : 8 : ... 

The same function, written using GHC's parallel list comprehension syntax (GHC extensions must be enabled using a special command-line flag '-fglasgow-exts'; see GHC's manual for more): List comprehensions are a programming language construct similar to the set-builder notation (set comprehensions), i. ...

 fibs = 0 : 1 : [ a+b | a <- fibs | b <- tail fibs ] 

The factorial we saw previously can be written as a sequence of functions:

 fac n = (foldl (.) id [&# 0;> x*k | k <- [1..n]]) 1 

A remarkably concise function that returns the list of Hamming numbers in order: Hamming numbers are a series of numbers first defined by Richard Hamming. ...

 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 

Like the various fibs solutions displayed above, this uses corecursion to produce a list of numbers on demand, starting from the base case of 1 and building new items based on the preceding part of the list.


In this case the producer is defined in a where clause as an infix operator represented by the symbol #. Apart from the different application syntax, operators are like functions whose name consists of symbols instead of letters.


Each vertical bar | starts a guard clause with a guard before the equals sign and the corresponding definition after the equals sign. Together, the branches define how # merges two ascending lists into one ascending list without duplicate items.

See also wikibooks:Transwiki:List of hello world programs#Haskell for an example that prints text.

Criticism

Haskell has many advanced features not found in many other programming languages, but some of these features have been criticized as making the language too complex or difficult to understand. In particular, critiques of functional programming languages and non-mainstream programming languages apply to Haskell. In addition, there are complaints stemming from the purity of Haskell and its theoretical roots.[citation needed] Functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions. ...


Jan-Willem Maessen, in 2002, and Simon Peyton Jones, in 2003, discussed problems associated with lazy evaluation whilst also acknowledging the theoretical motivation for it[9][10], in addition to purely practical considerations such as improved performance.[11] They note that, in addition to adding some performance overhead, laziness makes it more difficult for programmers to reason about the performance of their code (specifically with regard to space usage). Simon Peyton Jones is a British computer scientist who does research on the implementation and applications of functional programming languages, particularly lazy functional languages. ...


Bastiaan Heeren, Daan Leijen, and Arjan van IJzendoorn in 2003 also observed some stumbling blocks for Haskell learners, "The subtle syntax and sophisticated type system of Haskell are a double edged sword -- highly appreciated by experienced programmers but also a source of frustration among beginners, since the generality of Haskell often leads to cryptic error messages." [12] To address these, they developed an advanced interpreter called Helium which improved the user-friendliness of error messages by limiting the generality of some Haskell features, and in particular removing support for type classes. Helium is a compiler and a dialect of the functional programming language Haskell. ...


Implementations

The following all comply fully, or very nearly, with the Haskell 98 standard, and are distributed under open source licenses. There are currently no proprietary Haskell implementations. Open source refers to projects that are open to the public and which draw on other projects that are freely available to the general public. ...

  • The Glasgow Haskell Compiler compiles to native code on a number of different architectures—as well as to ANSI C—using C-- as an intermediate language. 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.
  • Gofer was an educational version of Haskell, developed by Mark Jones. It was supplanted by Hugs (see below).
  • HBC is another native-code Haskell compiler. It has not been actively developed for some time, but is still usable.
  • Helium is a newer dialect of Haskell. The focus is on making it easy to learn by providing clearer error messages. It currently lacks typeclasses, rendering it incompatible with many Haskell programs.
  • Hugs, the Haskell User's Gofer System, 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.
  • Jhc is a Haskell compiler written by John Meacham emphasising speed and efficiency of generated programs as well as exploration of new program transformations.
  • nhc98 is another bytecode compiler, but the bytecode runs significantly faster than with Hugs. Nhc98 focuses on minimizing memory usage, and is a particularly good choice for older, slower machines.
  • Yhc, the York Haskell Compiler is a fork of nhc98, with the goals of being simpler, more portable, more efficient and integrating support for Hat, the Haskell tracer.

The Glasgow Haskell Compiler (or GHC) is an open source Native code Compiler for the functional programming language Haskell which was developed at the University of Glasgow. ... ANSI C (Standard C) is a variant of the C programming language. ... C-- is an intermediate language, intended to be emitted by compilers instead of the C programming language or machine-specific assembly language. ... In computer science, an intermediate language is the language of an abstract machine designed to aid in the analysis of computer programs. ... OpenGL (Open Graphics Library) is a standard specification defining a cross-language cross-platform API for writing applications that produce 3D computer graphics (and 2D computer graphics as well). ... Helium is a compiler and a dialect of the functional programming language Haskell. ... Hugs (Haskell Users Gofer System) (also Hugs 98) is a bytecode interpreter for the functional programming language Haskell. ... Bytecode is a binary representation of an executable program designed to be executed by a virtual machine rather than by dedicated hardware. ... The York Haskell Compiler (or Yhc) is an open source bytecode compiler for the functional programming language Haskell; it primarily targets the Haskell 98 standard. ...

See also

Wikibooks has a book on the topic of

Image File history File links Wikibooks-logo-en. ... Wikibooks logo Wikibooks, previously called Wikimedia Free Textbook Project and Wikimedia-Textbooks, is a wiki for the creation of books. ... OHaskell is an object-oriented, concurrent extension of the functional programming language Haskell. ... Object-oriented programming (OOP) is a programming paradigm that uses objects to design applications and computer programs. ... Parallel programming (also concurrent programming), is a computer programming technique that provides for the execution of operations concurrently, either within a single computer, or across a number of systems. ... Pugs is a compiler and interpreter for the Perl 6 programming language, started on February 1, 2005 by Audrey Tang. ... Perl 6 is a planned major revision to the Perl programming language. ... Lolita (1955) is a novel by Vladimir Nabokov. ... Darcs is a distributed revision control system by David Roundy designed to replace the centralized CVS. Several noticeable differences in the design aim for simple use and powerful features. ... This article is being considered for deletion in accordance with Wikipedias deletion policy. ...

References

  1. ^ Paul Hudak, John Hughes, Simon Peyton Jones, Philip Wadler, "A History of Haskell: being lazy with class".
  2. ^ Preface. Haskell 98 Language and Libraries: The Revised Report (December 2002).
  3. ^ The History of Haskell.
  4. ^ Simon Peyton Jones (editor) (December 2002). Haskell 98 Language and Libraries: The Revised Report.
  5. ^ Future development of Haskell.
  6. ^ Welcome to Haskell'. The Haskell' Wiki.
  7. ^ list comprehension has been adopted by Python (programming language)
  8. ^ Linspire/Freespire Core OS Team and Haskell. Debian Haskell mailing list (May 2006).
  9. ^ Jan-Willem Maessen. Eager Haskell: Resource-bounded execution yields efficient iteration. Proceedings of the 2002 ACM SIGPLAN workshop on Haskell.
  10. ^ Simon Peyton Jones. Wearing the hair shirt: a retrospective on Haskell. Invited talk at POPL 2003.
  11. ^ Lazy evaluation can lead to excellent performance, such as in The Computer Language Benchmarks Game[1]
  12. ^ Bastiaan Heeren, Daan Leijen, Arjan van IJzendoorn. Helium, for learning Haskell. Proceedings of the 2003 ACM SIGPLAN workshop on Haskell.

Simon Peyton Jones is a British computer scientist who does research on the implementation and applications of functional programming languages, particularly lazy functional languages. ... Python is a high-level programming language first released by Guido van Rossum in 1991. ... The Association for Computing Machinery, or ACM, was founded in 1947 as the worlds first scientific and educational computing society. ... POPL is the annual symposium on Principles of Programming Languages sponsored by the Association for Computing Machinery Special Interest Groups SIGPLAN and SIGACT. SIGPLAN POPL homepage Categories: | | | ...

External links

Tutorials

Wikibooks has a book on the topic of

  Results from FactBites:
 
Haskell programming language (454 words)
In the 1980s, a committee was formed to create a standardized functional programming language with lazy evaluation.
Haskell is, as of 2002, the functional language on which the most research is being performed.
Its biggest deviation from Haskell is in the use of Uniqueness types for input as opposed to Monads.
Haskell: Information from Answers.com (1990 words)
The committee's efforts resulted in a series of language definitions which in late 1997 culminated in Haskell 98, intended to specify a stable, minimal, portable version of the language and an accompanying standard library for teaching and as a base for future extensions.
Haskell has many advanced features not found in many other programming languages, but some of these features have been criticized as making the language too complex or difficult to understand.
Jhc is a Haskell compiler written by John Meacham emphasising speed and efficiency of generated programs as well as exploration of new program transformations.
  More results at FactBites »

 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your location
Your comments
Please enter the 5-letter protection code


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms.