Week 6: Notes

There was no lecture or tutorial this week.

This week we will begin our study of the Haskell language. In our first weeks of learning Haskell we will follow the textbook Learn You a Haskell For Great Good! by Miran Lipovača, which is freely available online.

In this class we will use GHC (the Glasgow Haskell Compiler). You will want to download and install it now.

Haskell is a popular purely functional language with lazy evaluation and a static polymorphic type system using type inference. If you don't know what those terms mean, the section So what's Haskell? in the Lipovača text will give you a brief overview, and your understanding will become clearer as we use Haskell in the weeks to come.

Because Haskell is a purely functional language, the core language has no mutable variables or data structures. For example, if you set a variable x to have the value 7, it can never change after that. Furthermore, the core language has no concept of sequential execution, i.e. performing one task followed by another. So there are no while or for loops, which are inherently sequential. If you want to visit all elements of a list or other data structure, you must use recursion (or a higher-order function which is itself implemented using recursion). In these respects Haskell is quite different from traditional languages such as C or Java. On the other hand, the core of Prolog also has no mutable data, so you already have experience programming in a language that is somewhat similar in this respect.

Our goal this week is to learn enough of the Haskell language that we can start writing simple recursive functions using lists and tuples. Specifically, we want to learn about these topics:

To learn these features, please read the following sections of Learn You a Haskell:

  1. Introduction (all sections)

  2. Starting Out: Ready, set, go!, Baby's first functions, An intro to lists, Tuples

  3. Types and Typeclasses: (all sections)

  4. Syntax in Functions: Pattern matching, Let it be

You do not yet need to read about ranges, list comprehensions, guards, or where; we will visit those topics in the weeks to come.