## 1. Introduction to the course.

**Topics**: The goal of the course. Course Materials. Organization. Evaluation orders. Lazyness. Type classes.**Reading**: Chapters 1–6, Chapters 8–10 (mostly repetition of what you have seen in Introduction to Functional Programming at Chalmers). Note that it is ~200 pages, so start reading now if you need an update!**Optional reading**:- Applicative Functors are introduced in Real World Haskell Chapter 10, used more later in the same book Chapter 16.
- Haskell — The Craft of Functional Programming: Chapter 12 on overloading, Chapter 16 on abstract types, and Chapter 17 on laziness.
- The Haskell School of Expression: Chapter 12 on type classes, Chapter 14 on streams, Section 18.1 on higher-order types.

## 2. Domain Specific Embedded Languages (EDSL).

**Topics**: Developing EDSL for describing shapes (e.g., squares, disc, etc.) and signals (to represent change of values over time). Shape animation. Deep vs. shallow embedding. Compositionality and abstraction.**Reading**: DSL for the Uninitiated by Debasish Ghosh, Chapter 5 has a EDSL for pretty printing, Chapter 9 for file searching and Chapter 13 one for arithmetic expressions.**Exercises**:- Shape: extend the library with colored shapes
- Shape: define derived opertations
`x-reflection`

,`y-reflection`

, and`zoom_in`

- Signal: define
`mapS`

as a derived operation

## 3. Monads

**Topics**: Side-effects in pure functional programming. Monads. Monads for error handling, logging, and state. Monads and EDSL.**Reading**: Chapter 14**Optional reading**:- Chapter 15
- Monads for functional programming by Philip Wadler (the interpreter for arithmetic expressions is taken from this paper)

## 4. Functors, Applicative Functors, and Monads

**Topics**: Functors. Applicative functors. Relation among functors, applicative functors, and monads. More example of monads (modeling IO).**Reading**: Chapter 10 (Section Introducing Functors), FUNCTIONAL PEARL Applicative programming with effects (Page 1 – 6)**Optional reading**:- Functors: Page 1 and 2 from "Functional Pearl: F for Functor" by R. Hinze, J. Hackett, and D. W. H. James
- Applicative functors: FUNCTIONAL PEARL Applicative programming with effects
- Blog on Functors are containers by B. Milewski. This blog post explains Functors, Applicative Functors, and Monads using the concept of containers.
- Intermediate embedding: Beauty in the Beast, A Functional Semantics for the Awkward Squad by W. Swierstra and T. Altenkirch Sections 1, 2 and 3.

## 5. Parser derivation

**Topics**: Another application of monads, namely parsing. Refinement of implementation by program derivation. The focus here is on learning outcome "Spec: use specifictaion based development techniques".**Reading**: Chapter 16, until p. 390 or so; to get a feel for what parser combinators are, Parallel Parser Combinators, Koen's slides**Optional reading**:Monadic Parser Combinators by Graham Hutton and Erik Meijer.

The Design of a Pretty-printing Library by John Hughes.

## 6. Monad transformers

**Topics**: we learn how to build complicated monads from simple building blocks. We cover the reader and state monad transformers. We apply them to write a interpreter for simple expressions.**Reading**: Chapter 18 on Monad Transformers.**Optional reading**:- Monad Transformers and Modular Interpreters by Sheng Liang, Paul Hudak, and Mark Jones.

## 7. Monad transformers II

**Topics**: This lecture looks into the consequences of the application order of`StateT`

and`ExceptT`

monad transformers in the interpreter. The lecture also shows how to create your own monad transformers — for that, we show an implementation for`StateT`

,`ExceptT`

, and`ReaderT`

.The reading material is the same as lecture 6 (see above).

## 8. Information-flow Control in Haskell

**Topics**: In this lecture, we will see a use of monads for controlling effects in order to provide security for Haskell programs. We will focus on how to preserve sensitive data when executed by untrusted code, i.e., code written by someone else.

**Reading**: Functional Pearl: Two can keep a secret, If one of them uses Haskell by A. Russo

## 9. Program verification

**Topics**: In this lecture, we look at program verification by proving properties by induction. We also explore property-based testing as increasing the confidence on program correctness.**Reading**: Chapter 11. Chapter 2 in the book*The Fun of Programming*.**Optional reading**: QuickCheck: A Lightweight Tool for Random Testing of Haskell Programs by K. Claessen and J. Hughes

## 10. Type-based modeling

**Topics**: We look how to do type-inference (type-checking) in DSL using GADTs. We describe existential and singleton types.**Reading**: Existentially qualified types and GADTs.

## 11. Type-based modeling II & looking back!

**Topics**: In the first part of the lecture, we will discuss associated types, kinds, data kinds, type families, and singleton types. In the second part, the lecture briefly look back at the learning outcomes and how they relate to the different parts of the course and what parts of the Real world Haskell book are covered. Then we go through a few examples chosen by popular vote by the participants.**Reading**: Type families on the Haskell Wiki, and Associated types in S. Peyton-Jones' slides**Optional reading**: Fun with Type Functions by O. Kiselyov, S. Peyton-Jones, and C. Shan

# Special lectures

## Looking forward! (Thursday, February 15th)

## Looking forward! (Monday, February 26th)

**Topics**: Second instance of the excercise session with exam questions.

## Guest lecture 1 by Dominic Orchard (Thursday, March 1st)

**Material**: Slides and code

~~Guest lecture 2 by Andreas Abel (Monday, March 5th)~~

- This guest lecture has been canceled due to sickness. We will have a regular lecture instead, room EF.