Get Started With Haskell

The Haskell programming language was named after the logician Haskell Brooks Curry, whose work on mathematical logic is used as a foundation for functional programming languages.

Haskell also implements the Lambda calculus, so the logo chosen for Haskell contains a stylized lambda symbol.

What Is Haskell?

Haskell is a standardized, general-purpose, multi-paradigm, purely functional programming language, with lazy evaluation, non-strict semantics and strong static typing.

Being a purely functional language means that functions in Haskell do not have side-effects, with a separate construct provided for representing side effects — orthogonal.

Haskell has an open, published specification and many Haskell implementations exist under various open-source licenses. Glasgow Haskell Compiler (GHC) is the main implementation of Haskell and it has become the de facto standard Haskell dialect.

Haskell is widely used in educational programming courses and industry. For example, all of the following are implemented in Haskell:

  • The Xmonad window manager

  • Darcs revision control system

  • Linspire system tools development

  • Bluespec SystemVerilog semiconductor design tools

  • Facebook anti-spam protection

  • Cryptol cryptographic algorithms verification.

Brief History

Interest in lazy functional programming languages grew after the release of Miranda, a lazy programming language, in 1985.

During the Functional Programming Languages and Computer Architecture conference in Portland, a meeting was held where participants came to a strong consensus to form a committee which should define an open standard for such programming languages.

Haskell version 1.0 was defined in 1990, based on the semantics of Miranda, but with a different syntax.

The committee's continued work resulted in a range of further language definitions, from 1.0 to 1.4. Haskell 98, released in late 1997, specified a minimal and stable version of the language, with an accompanying library as a strong base for further development.

Haskell 2010, published in July 2010, is the latest stable release. This Haskell release introduces support for the foreign function interface (FFI), which allows for bindings to other programming languages.

Features

Haskell is a statically typed programming language, making use of the Hindley-Milner type system to ensure type safety. The language also introduced type classes — its main innovation.

Haskell is purely functional, so every function in Haskell is a function in the pure mathematical sense; there are no statements or instructions.

In a Haskell program, you do not have to explicitly define types, they can be inferred by unifying. Types can still be strictly defined in code, if you choose to do so.

Haskell is lazy evaluated, which means that functions do not evaluate their arguments, allowing for easy definition of control structures and optimal reuse of code.

Like other functional programming languages, Haskell features an automatic memory management system through garbage collection, where memory is automatically allocated and freed-up by the garbage collector.

Getting Started With Haskell

If you have previous experience in programming methods and logic, or other functional programming languages, getting started with Haskell programming should not pose a big problem.

Your Development Environment

Before you can start coding in Haskell, you'll need a development environment. We suggest using the Glasgow Haskell Compiler (GHC) included in the Haskell Platform download, since it is the most popular compiler for the Haskell programming language.

It is currently available on the big three operating systems: Mac OS X, Linux, and Windows.

Installing Haskell on these operating systems is easily done and well documented, simply choose the right download for your OS at the Haskell Platform download page, and follow the installation instructions.

Resources

We did a bit of research to find the best Haskell tutorials, e-books, interactive courses, and other resources. We suggest you try using multiple resources and work your way up to more complex exercises and projects.

Haskell Courses and Tutorials

To see what Haskell can do, you need to give it a hands-on try. These tutorials and courses provide a good starting point:

  • A Gentle Introduction to Haskell, Version 98 by Hudak, Peterson, Fasel is a free step by step tutorial to Haskell. A free download available.

  • Yet Another Haskell Tutorial (pdf) by Hal Daume is a very good, free Haskell tutorial providing a comprehensive and practical introduction to Haskell programming.

  • Try Haskell is an online IDE that can run Haskell code, with an embedded short tutorial as well. This is a good place to quickly try some Haskell code.

  • School of Haskell has some good learning materials, articles and tutorials, both for beginners and more experienced Haskell programmers.

  • Haskell.org has a very good documentation section, where you can find various books, courses, tutorials and other resources for Haskell programming.

Additional Resources

Working through tutorials and official programming language reference with sample code can help you to understand Haskell programming much better than theoretical resources. These are some of the most comprehensive and detailed resources for Haskell:

Once you make it through the resources and tutorials listed above, you should have a basic understanding of Haskell programming.

Books

We have singled out a few books covering several aspects of Haskell programming. Most of these e-books come recommended by Haskell educators and they will be useful resources for anyone trying to master the language:

  • Real World Haskell by O'Sullivan, Stewart, and Goerzen. This book will show you how to use functional programming and Haskell to solve realistic everyday problems. Available as a free download or for purchase.

  • Learn You a Haskell for Great Good! by Miran Lipovaca is a fun, illustrated guide to this complex functional language. Packed with the author's original artwork, and useful example code, this book teaches functional fundamentals in a way you never thought possible. Available as a free download or for purchase.

  • The Haskell Road to Logic, Math and Programming by Doets and van Eijck will show you logic and mathematical reasoning in practice, and connect logical reasoning with Haskell programming.

Summary

With this introduction and these resources, you should be on your way to becoming a functional programming expert with Haskell.