Numbers are values. Strings are values. Booleans are values. In "functional programming", functions are "simply" values as well. This view on programming leads to an elegant and expressive programming paradigm which we will investigate in this course. During the course, we will use the programming language Haskell. The majority of the concepts we will consider applies in other (functional) languages as well.
Participants are not expected to be fluent in Haskell from the beginning. We will spend the first three weeks of the semester on a Haskell Ramp-Up. Things will progress rather fast, though. The majority of the semester will be used for the good stuff: intermediate and advanced topics, of which there are plenty.
Discussion around this course and Haskell in general are encouraged in the forum. Please stop by regularly, have a look, and say "hi".
Regular weekly tutorials will only start on Monday, Nov 2.
Weekly exercise sheets are provided on the teaching platform ILIAS. Exercises are handed out (and submitted by you, a week later) Thursdays, at 10am.
You are admitted to the final exam if you score at least ⅔ of the overall exercise points.
Scoring well in the exercises leads to substantial bonus points in the final exam (up to ⅓ of the overall exam points).
The course will use the de-facto standard Haskell compiler GHC and its interactive variant (also known as read-eval-print loop or REPL) GHCi. We strongly suggest you download and install the so-called Haskell Platform which includes both GHC and GHCi (and more). Available for virtually all operating systems, including Windows, Linux, OS X. Make sure to install the recent version 7.10.2.
The following introductory books and courses on Haskell are recommend reading — some of these are available online:
We will refer to additional material for the individual topics during the semester.
The Hello, World! of Haskell.
Declares a user-defined infix operator
Conditional expression vs. guards
Function definition using guards and local
Conditional expression vs. guards vs. pattern matching
Compute a finite prefix of an (infinite) list — demonstrates pattern matching
Mergesort (with a user-defined ordering relation) — demonstrates pattern matching, local
Demonstrates algebraic sum types (enumerations)
Demonstrates algebraic product types
Demonstrates algebraic sum-of-product types (cons lists)
Use algebraic data types to represent, evaluate, compile, and execute simple arithmetic expressions
Implements integer sets as unordered lists, implementation fully exposed
Shallow embedding of a DSL for integer sets (uses a Haskell module to hide the implementation in terms of characteristic functions)
Imports and exercises the shallow integer set DSL embedding in
Deep embedding of a DSL for integer sets (observers
Imports and exercises the deeply embedded integer set DSL in module
Deep embedding of a super-simple expression language (with
Using GADTs to construct a type-safe deeply embedded DSL over integers and Booleans.
Shallow embedding of a DSL for expressions with
A shallowly embedded DSL for string pattern matching. Based on Philip Wadler's seminal 1985 paper Replacing Failure by a List of Successes.
Sequencing partial functions
Sequencing exception-generating functions
Sequencing stateful functions
Monadic sequencing of partial functions
Monadic sequencing of exception-generating functions
Monadic sequencing of non-deterministic functions (i.e., relations)
Monadic sequencing of stateful functions
Demonstrates how the construction of IO actions is decoupled from their effectful execution (free monad
Super-simple demonstration of the
Throwing one die/two dice and the resulting probability distribution (uses
Spark profile can be inspected via ThreadScope.
Making a user-defined algebraic data type an instance of class
A parallel variant of
Wrapper that measures execution time of
Parallel monoid reduction (
Illustration: Splitting an input text into its whitespace-separated words. A formulation of the problem in terms of
Uses parallel monoid reduction (over monoid