Lectures

Work in progress

The lectures below are step by step migrated from the previous course instance (labelled "2012:" below) to the current 2013 instance.

Lecture 1 - Course Intro and Haskell Recap

  Mon study week 1, 13.15 - 15.00 in EL43

In this lecture we do a quick recap of Haskell and talk about things like referential transparency, laziness, type classes, and a first simple example of a domain specific embedded language: Signal.)

Slides

[odp] [pdf]

Code

Signal   [code]

Links

Reading

Related papers

Lecture 2 - Case study: Shapes

  Thu study week 1, 10.00 - 11.45 in EL43

In this lecture we develop domain specific embedded languages for describing signals and shapes. We talk about the distinction between a deep and a shallow embedding, about compositionality and abstraction.

Slides

[odp] [pdf]

Code

Matrix   [code]
Signal   [code]
Signal.Shallow   [code]
Signal.Deep   [code]
Signal.Example   [code]
Shape   [code]
Shape.Shallow   [code]
Shape.Deep   [code]
ANSI   [code]
Render   [code]
Animate   [code]
Example   [code]

Links

Reading

Exercises

Lecture 3 - Monads

  Mon study week 2, 13.15 - 15.00 in EL43

This lecture introduces monads by looking at how to design a simple library for input/output.

Code

Program.Shallow   [code]
Program.Deep1   [code]
Program.Deep2   [code]
Program   [code]
Game   [code]
Coord   [code]
Snake   [code]

Links

Exercises

Reading

Related papers

Lecture 4 - Parsing

  Thu study week 2, 10.00 - 11.45 in EL43

In this lecture we look at another application of monads, namely parsing. We also see how to refine the implementation of a library. Starting from a naive translation from syntax to semantics, we derive intermediate representations for an efficient implementation. The focus here is on learning outcome "Spec: use specifictaion based development techniques".

Slides

Koen's slides

Links

Code

ParseUtil   [code]
Parsers   [code]
Parser0   [code]
Parser1   [code]
Parser2   [code]
Parser3   [code]
exe/Example   [code]

Exercises

Reading

Related papers

Lecture 5 - Monad transformers

  Mon study week 3, 13.15 - 15.00 in EL43

We learn how to build complicated monads from simple building blocks.

Code

MonadT_API_summary   [code]
Interpreter0   [code]
Interpreter1   [code]
Interpreter2   [code]
Interpreter3   [code]
Interpreter4   [code]
Examples   [code]
Parser   [code]

Links

Exercises

Reading

Related papers

Lecture 6 - Program verification

  Thu study week 3, 10.00 - 11.45 in EL43

We look at program verification: proving, specifying and testing correctness of programs.

Slides

[pdf]

Code

InsertionSort   [code]

Reading

Related papers

Lecture 7 - Type based modelling

  Mon study week 4, 13.15 - 15.00 in EL43

We look at two recent extensions to Haskell: GADTs and Type families.

Code

Expr   [code]
Typed   [code]
Parser   [code]
Add   [code]
Array   [code]
Array/Properties   [code]
Array/Example   [code]
Array/ShowInstances   [code]
Array/EqInstances   [code]

Links

Reading

Links

Related papers

Lecture 8 - Looking forward!

  Thu study week 4, 10.00 - 11.45 in EL43

In this lecture / excerices session we will work through old AFP exam questions in groups to identify important topics and practice collaborative problem solving and discussion. This is in response to student comments from last year wanting more practice of the kind of problems typically included in the written exams.

Lecture 9 - Feldspar: guest lecture by Emil Axelsson

  Mon study week 5, 13.15 - 15.00 in EL43

Feldspar is an embedded language for high-performance numeric processing. Its development is motivated by the need to raise the abstraction level of signal processing code in Ericsson's radio base station. In this lecture I will present Feldspar with a special focus on its implementation in Haskell.

Links

Lecture 10 - More testing and coverage checking

  Thu study week 5, 10.00 - 11.45 in EL43

In this lecture we continue the work on QuickCheck, mainly looking at how to generate and shrink test data. We may also look at the different stackings of the monad transformers in the Interpreter4 example (from the MonadTransformes lecture). We also check out how the program coverage tool hpc can be used to see what parts of a program has been tested.

Code

ParserTests   [code]

Reading

Links

Lecture 11 - Advanced Functional Programming: An Agda Tutorial

  Mon study week 6, 13.15 - 15.00 in EL43

In dependently typed languages such as Agda one can both write programs and proofs about the programs. Agda can be seen as a "next generation Haskell".

Links

Lecture 12 - Programs and proofs in Agda: guest lecture by Nils Anders Danielsson

  Thu study week 6, 10.00 - 11.45 in EL43

In dependently typed languages such as Agda one can both write programs and prove propositions which refer to the programs. Building on Patrik's introduction to Agda I will implement a very simple theorem prover, and formally prove that it is sound.

Code

Prelude   [code]
Proof-by-reflection   [code]

Lecture 13 - Lazy SmallCheck (guest lecture by Fredrik Lindblad)

  Mon study week 7, 13.15 - 15.00 in EL43

Lazy SmallCheck is a testing tool for Haskell which is based on exhaustive enumeration of test cases (instead of random test case generation). It uses lazy narrowing, a search mechanism suitable for functional programming languages which exploits non-strictness. In the lecture I will present lazy narrowing, how the tool is implemented as a library using type reflection and exception trapping, and how to use the tool for testing (contrasting it to QuickCheck).

Links

Lecture 14 - Looking back

  Thu study week 7, 10.00 - 11.45 in EL43

In this lecture we look back at the learning outcomes and how they relate to the different parts of the course and what parts of the RWH book are covered. Some other relevant topics did not fit but I include references and code below.

Code

RWMonad   [code]
MaybeT/Deep   [code]
MaybeT/Shallow   [code]

Code

FFI   [code]
foreign.c
Cont   [code]
Memo   [code]
Generics   [code]
NoGenerics   [code]

Links

[Chalmers]
[GU]