Different ap­proaches have always existed in software de­vel­op­ment: Pro­gram­ming paradigms, for example, determine how programs are written and the way in which program codes are struc­tured. The most popular ap­proaches include func­tion­al pro­gram­ming. This, in turn, is a sub-form of the de­clar­at­ive approach, in which only results, and not the steps leading to them, are described. An es­tab­lished rep­res­ent­at­ive of this category is the pro­gram­ming language Haskell named after the American math­em­atician Haskell Brooks Curry.

Below, you will find out what Haskell is, how the language differs from other pro­gram­ming languages, and for which projects it is best suited.

What is Haskell?

Haskell is a purely func­tion­al pro­gram­ming language, the first version of which was published in 1990. The namesake was the math­em­atician Haskell Brooks Curry, who laid the found­a­tion for func­tion­al pro­gram­ming languages with his work on com­bin­at­ory logic (between 1920 and 1960). Haskell is based on lambda calculus (a formal language for examining functions), which is why the Greek letter Lambda is also part of the language’s official logo.

Programs written in Haskell are always rep­res­en­ted as math­em­at­ic­al functions. These functions never have secondary or side effects. With the same input, each function used always delivers the same result and never changes the status of a program. The value of an ex­pres­sion or the result of a function therefore only depends on the current input para­met­ers. There are no im­per­at­ive language con­struc­tions for pro­gram­ming a sequence of in­struc­tions in Haskell.

Vgu82wiiZ90.jpg To display this video, third-party cookies are required. You can access and change your cookie settings here.

After its pub­lic­a­tion, Haskell became a kind of standard for func­tion­al pro­gram­ming languages. As a result, numerous de­riv­at­ives such as Parallel Haskell, Eager Haskell, Haskell ++, and Eden were developed that are closely related to Haskell. Some entirely new pro­gram­ming languages are also based on Haskell. The universal language Python, one of the most important modern Internet pro­gram­ming languages, has adopted the Lambda notation and the Haskell list pro­cessing syntax, for example.

What can be done with Haskell as a pro­gram­ming language?

It takes a lot of work, time, and money to develop and maintain large software projects. Func­tion­al pro­gram­ming languages such as Haskell can provide relief. Haskell is a par­tic­u­larly at­tract­ive option thanks to the following ad­vant­ages:

  • Developer pro­ductiv­ity can be sig­ni­fic­antly increased.
  • The code for Haskell software is short, clear, and easy to maintain.
  • Haskell ap­plic­a­tions are less prone to errors and offer high re­li­ab­il­ity.
  • The 'se­mantic' gap between pro­gram­mer and language is minimal.

As such, Haskell is suitable as a pro­gram­ming language for a wide range of ap­plic­a­tions. The func­tion­al language is par­tic­u­larly pre­destined for programs that should offer a high degree of modi­fi­ab­il­ity and ease of main­ten­ance. Haskell’s strengths also come into play when it comes to de­vel­op­ing spe­cific­a­tions and pro­to­types that can actually be executed, and thus tested and debugged.

In in­dus­tries in which the exact mapping of math­em­at­ic­al al­gorithms is required, Haskell is commonly chosen as a pro­gram­ming language. Typical examples are ap­plic­a­tions for network security, spe­cific­a­tion frame­works for embedded systems, and programs for modelling complex math­em­at­ic­al cal­cu­la­tions.

Note

Haskell is not a suitable choice for pro­gram­ming simple programs.

How does Haskell differ from other pro­gram­ming languages?

As a purely func­tion­al pro­gram­ming language, Haskell stands out from many other languages. In par­tic­u­lar, its dif­fer­ences from languages that are based on the im­per­at­ive pro­gram­ming paradigm are sig­ni­fic­ant: Programs that are written in im­per­at­ive languages execute sequences of in­struc­tions. The status of these in­struc­tions can change during execution by changing variables, for example. Control flow struc­tures ensure that in­struc­tions can be executed multiple times.

In the func­tion­al approach on which Haskell is based, the software does not give the computer any direct commands as to how it should do something. Instead, the problem or its solution is described. Variables are undynamic: A variable with the value ‘1’ has a permanent value of ‘1’ in Haskell and other func­tion­al languages, and cannot just be easily changed. Functions only serve the purpose of cal­cu­lat­ing something and returning the cor­res­pond­ing result.

Learning Haskell: re­quire­ments, tips, and a first example

Learning Haskell can pay off for several reasons: First, you can sub­sequently program your own software solutions in Haskell, provided that the language is suitable as a basis. In addition, you are well prepared if you have to deal with third-party ap­plic­a­tions that are written in Haskell. Since Haskell is also a kind of standard for func­tion­al pro­gram­ming languages, learning it is also worth­while if you want to build up a general know-how of func­tion­al pro­gram­ming.

As with many other languages, you have two options for pro­cessing Haskell code: in batches with a compiler or in­ter­act­ively with an in­ter­pret­er. An in­ter­act­ive system has the advantage of providing a suitable command line in which you can ex­per­i­ment directly and evaluate ex­pres­sions. For a simple in­tro­duc­tion to the Haskell pro­gram­ming language, this is prefer­able in any case. One of the best known examples is the in­ter­pret­er Hugs, which is no longer actively developed. Al­tern­at­ively, GHC (Glasgow Haskell Compiler) provides the practical complete package of a Haskell in­ter­pret­er and compiler.

Tip

Exactly how the op­er­a­tions and func­tion­al­it­ies of in­ter­pret­ers and compilers differ is revealed in our article 'Compiler vs. In­ter­pret­er – Defin­i­tion and Dif­fer­ences'.

The following code snippet provides a simple example of how Haskell works:

add :: Integer -> Integer -> Integer    --function declaration
add x y =  x + y                              --function definition
main = do
    putStrLn "The sum of the two numbers is:"
    print(add 2 5)     --calling a function

In line 1 of the code, the Haskell function is declared, which should have integers (whole numbers) as input and output values. The function is spe­cific­ally defined in line 2: Two arguments are added, and the addition result should be presented. The two values '2' and '5' are supplied as input. The execution of this snippet leads to the following output:

The sum of the two numbers is: 7
Tip

Further tips and tricks for getting started with the syntax and func­tion­al­ity of Haskell are available in our extensive Haskell tutorial.

Go to Main Menu