|
Haskell is a standardized pure functional programming language with non-strict semantics, named after the logician Haskell Curry. It was created by a committee formed in 1987 for the express purpose of defining such a language. The direct predecessor of Haskell was Miranda, devised in 1985. The latest official language standard outside the standardization organizations is Haskell 98, intended to specify a minimal, portable version of the language for teaching and as a base for future extensions. 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). ...
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. ...
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 is a bytecode interpreter for 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...
Python is an interpreted programming language created by Guido van Rossum in 1990. ...
Purely functional is a term in computing used to describe algorithms, data structures or programming languages that exclude destructive modifications (updates). ...
Functional programming is a programming paradigm that conceives computation as the evaluation of mathematical functions and avoids state and mutable data. ...
A programming language is an artificial language that can be used to control the behavior of a machine (often a computer). ...
A strict programming language is one in which only strict functions may be defined by the user. ...
Haskell Brooks Curry (September 12, 1900, Millis, Massachusetts - September 1, 1982, State College, Pennsylvania) was an American mathematician and logician. ...
1987 (MCMLXXXVII) was a common year starting on Thursday of the Gregorian calendar. ...
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 is about the year. ...
The language continues to evolve rapidly, with Hugs and GHC (see below) representing the current de facto standard. Hugs 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. ...
De facto is a Latin expression that means in fact or in practice. It is commonly used as opposed to de jure (meaning by law) when referring to matters of law or governance or technique (such as standards), that are found in the common experience as created or developed without...
Characterizing syntax features in Haskell include pattern matching, currying, list comprehensions, guards, and definable operators. 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 computer science, currying is the technique of transforming a function taking multiple arguments into a function that takes a single argument (the first of the arguments to the original function) and returns a new function that takes the remainder of the arguments and returns the result. ...
List comprehension is a programming language construct for list processing, 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 would be written as: S = [ x | x<-[0. ...
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. ...
A Sierpinski triangle âa confined recursion of triangles to form a geometric lattice. ...
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. ...
Some functional programming languages, particularly Haskell, make use of the monad concept from category theory, a branch of mathematics that describes patterns applicable to many mathematical fields. ...
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. ...
The language is, as of 2002, the lazy 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. 2002 is a common year starting on Tuesday of the Gregorian calendar. ...
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. ...
Functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions. ...
The Massachusetts Institute of Technology, or MIT, is a private research university located in the city of Cambridge, Massachusetts, USA. Its mission and culture are guided by an emphasis on teaching and research grounded in practical applications of science and technology. ...
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. ...
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 deviation from Haskell is in the 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. ...
In computer science Clean is a general-purpose purely functional programming language. ...
In computing, a unique type guarantees that an object is used in a single-threaded way, without duplicating references to it. ...
Some functional programming languages, particularly Haskell, make use of the monad concept from category theory, a branch of mathematics that describes patterns applicable to many mathematical fields. ...
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. Darcs is a revision control system, with several innovative features. Linspire GNU/Linux chose Haskell for system tools development [1]. Audrey Tang Audrey Tang (Traditional chinese: åé³³; born April 18, 1981 as å宿¼¢, formerly known as Autrijus) is a Taiwanese free software programmer, best known for initiating and leading the Pugs project, a joint effort from Haskell and Perl communities to implement the Perl 6 language. ...
Pugs is an interpreter and compiler for the Perl 6 programming language, started on February 1st 2005 by Autrijus Tang. ...
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. ...
Linspire, previously known as LindowsOS (also Lin---s, pronounced as Lindash), is a GNU/Linux distribution based on Debian. ...
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. ...
In mathematics, the factorial of a natural number n is the product of all positive integers less than or equal to n. ...
fac :: Integer -> Integer fac 0 = 1 fac n | n > 0 = n * fac (n-1) Or in a single line: let { fac 0 = 1; fac n | n > 0 = n * fac (n-1) } This describes the factorial as a recursive function, with a single 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 Sierpinski triangle âa confined recursion of triangles to form a geometric lattice. ...
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: The C Programming Language, Brian Kernighan and Dennis Ritchie, the original edition that served for many years as an informal specification of the language The C programming language (often, just C) is a general-purpose, procedural, imperative computer programming language developed in the early 1970s by Dennis Ritchie for use...
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 A simple way to test such examples in the Hugs interpreter, as opposed to writing and compiling a full Haskell program, is to use a "where" clause. Enter the function name and parameters followed by where and then the function definition. fac 5 where 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. ...
More complex examples A simple RPN calculator expressed with a higher-order function whose argument f is defined in a where clause using pattern matching and the type class Read: Reverse Polish notation (RPN), also known as postfix notation, was invented by Australian philosopher and computer scientist Charles Hamblin in the mid-1950s, to enable zero-address memory stores. ...
In mathematics and computer science, higher-order functions are functions which can take other functions as arguments, and may also return functions as results. ...
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 resolves, 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; 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 List of hello world programs#Haskell for an example that prints text.
The following is a list of hello world programs. ...
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 levelled against functional programming languages and non-mainstream programming languages are applicable to Haskell. In addition, there are complaints stemming from the purity of Haskell and its theoretical roots. A programming language is an artificial language that can be used to control the behavior of a machine (often a computer). ...
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 discuss problems associated with lazy evaluation whilst also acknowledging the theoretical motivation for it. 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 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. 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.
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 commercial 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. ...
- Glasgow Haskell Compiler [2]. 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.
- Gofer An educational version of Haskell, Gofer was developed by Mark Jones. It was supplanted by HUGS.
- HBC [3] is another native-code Haskell compiler. It hasn't been actively developed for some time, but is still usable.
- Helium [4] 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 [5] 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 [6] a Haskell compiler written by John Meacham emphasising speed and efficiency of generated programs as well as exploration of new program transformations.
- nhc98 [7] 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.
- yhc [8] Yhc is a fork of nhc98, with the goals of being simpler, more portable, more efficient and integrating Hat support.
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. ...
OpenGL official logo 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). ...
Hugs is a bytecode interpreter for the functional programming language Haskell. ...
Byte-code is a sort of intermediate code that is more abstract than machine code. ...
See also Wikibooks has a manual, textbook or guide to this subject: Image File history File links Wikibooks-logo-en. ...
Wikibooks logo Wikibooks, previously called Wikimedia Free Textbook Project and Wikimedia-Textbooks, is part of the Wikimedia Foundation. ...
OHaskell is an object-oriented, concurrent extension of the functional programming language Haskell. ...
In computer science, object-oriented programming, OOP for short, is a computer programming paradigm. ...
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. ...
References - Simon Peyton Jones. Wearing the hair shirt: a retrospective on Haskell. Invited talk at POPL 2003.
- Jan-Willem Maessen. Eager Haskell: Resource-bounded execution yields efficient iteration. Proceedings of the 2002 ACM SIGPLAN workshop on Haskell.
- Bastiaan Heeren, Daan Leijen, Arjan van IJzendoorn. Helium, for learning Haskell. Proceedings of the 2003 ACM SIGPLAN workshop on Haskell.
The Association for Computing Machinery, or ACM, was founded in 1947 as the worlds first scientific and educational computing society. ...
External links -
- Yet Another Haskell Tutorial - a good Haskell tutorial by Hal Daume III; assumes much less prior knowledge than the official tutorial
- The Evolution of a Haskell Programmer - a slightly humorous overview of different programming styles available in Haskell
- An Online Bibliography of Haskell Research
|