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.
Weekly exercise sheets are provided on the teaching platform Ilias. Please register at the following link for the exercises: Functional Programming in Ilias. The first exercise sheet will be handed out on Monday, 14.04.2014 at 14:00.
The following introductory books on Haskell 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