Lectures

Work in progress

The lectures below are step by step migrated from the previous course instance (labelled "2013:" below) to the current 2014 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 - EDSL 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 - More from lectures 4 and 5

  Thu study week 3, 10.00 - 11.45 in EL43

In the course evaluation meeting after the 2013 instance we decided to dilute the first part of the course a bit: the material from lectures 2,3,4,5 are spread out over lecture slot 2-6. Concretely this means that this lecture was spent working through the StateT and ErrorT monad transformers in the interpreter example before the break and transforming looking at the Monad and Parser laws after the break. The code and the recommended reading material can be found above.

Lecture 7 - Program verification

  Mon study week 4, 13.15 - 15.00 in EL43

We look at program verification: proving, specifying and testing correctness of programs. (Lecturer: Jonas Duregård.)

Slides

[pdf]

Code

InsertionSort   [code]

Reading

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 - More testing and coverage checking

  Mon study week 5, 13.15 - 15.00 in EL43

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

Code

ParserTests   [code]

Reading

Links

Lecture 10 - Guest lecture by Emil Axelsson on EDSLs

  Thu study week 5, 10.00 - 11.45 in EL43

Title: Designing EDSLs by combining Deep and Shallow Embeddings

I will present a design pattern for embedded DSLs (EDSLs) where a combination of deep and shallow embeddings is used in order to get most advantages from both approaches. This approach has been successfully used in Feldspar which is an EDSL for high-performance numeric computations. I will also introduce Feldspar and discuss some details of its implementation.

Links

Related papers

Lecture 11 - Type based modelling

  Mon study week 6, 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 12 - Advanced Functional Programming: An Agda Tutorial

  Thu study week 6, 10.00 - 11.45 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 13 - Haskell in Scientific Computing (guest lecture)

  Mon study week 7, 13.15 - 15.00 in EL43

Abstract: Starting with a simple example from Richard Bird's "Introduction to Functional Programming", computing square roots (section 3.6.1, pp 84--85), we introduce some problems typical of today's scientific computing: finding derivatives, optimization, controlling floating-point errors. We'll implement simple automatic differentiation and interval analysis, exposing some of the advantages and disadvantags of Haskell's numerical typeclasses. You can find related material on the web page of the Oberwolfach seminar on "Mathematics for scientific computing" [1] in particular [2], [3] and the references within.

Micro-bio: Cezar Ionescu is currently a PostDoc on "Increasingly Correct Scientific Computing" in the FP group at Chalmers. Before that he worked for several years at the Potsdam Institute for Climate Impact Research where he applied AFP in the form of Haskell, C++, Agda and Idris to Computational Vulnarability Assessment, Scientific Computing and Economic Models.

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]