Functional Programming with Effects
This is a MSc-level seminar but we also welcome interested BSc students.
Purely functional programs don’t allow side-effects like reading or writing from the console (or network), mutable state, or exceptions. How then can those languages be used to solve real world problems?
In this seminar, we will cover various techniques to structure and program with effectful functional programs. Participants will learn the foundations of computational effects like monads, arrows and applicatives. Explicitly structuring programs with computational effects opens up the possibility for equational reasoning. Participants will learn how to instantiate those general concepts for particular use cases like parsing or functional reactive programming.
Entry in the alma-system: Link
The registration for the seminar is now closed.
This seminar will be conducted as a paper reading group with weekly meetings on Tuesdays, 14 c.t. in room C215 (this room is at Sand 14 on the first floor behind the library. If the latter is closed, it can only be accessed by using a separate stairway from the outside or by going up to the second floor, turning right, going through the hallway until just before the end and then back down the stairway on the left to the first floor (there are signs on the doors)).
Each week one of the students is the discussion leader, who familiarizes herself/himself with the paper’s content in greater depth. The other participants should also read the paper, prepare questions, and send them to the discussion leader.
During the session, the discussion leader will summarize the main points of each section, be ready to answer the other participants’ questions, keep the discussion on track, and point out additional insights gained by the in-depth preparation.
At the end of the semester, each participant will write a term paper on the topic prepared as discussion leader. It is also possible to accompany this with some artifact, e.g. a mini software project, that showcases practical applications discussed in the term paper.
We will have our first meeting on Wednesday, October 19 at 16 c.t. in room C215 (see above).
The slides of the first meeting.
Discussion Language: English or German (depending on participants)
Paper Language: English
Credits: 3 ECTS
There are no formal requirements. However, having attended some of the following lectures greatly helps to understand the papers more easily:
Most of the papers use the programming language Haskell or similar functional programming languages. It is thus also very helpful to have some prior exposition to functional programming (and to Haskell) as provided by the lecture Functional Programming (by the group of Torsten Grust).
Information on Reading Papers
In preparation for the seminar, we highly recommend to read the following short papers:
- P. W. L. Fong: Reading a Computer Science Research Paper
- S. Keshav: How to read a paper
The following is a preliminary list of papers you can choose from. We will read the papers in (roughly) that order. A list with related papers will follow shortly. Note that you need to be in the university network (or VPN) to access some of the papers as PDF. If you can’t find the PDFs you can also try searching on Google-Scholar.
Monads for Functional Programming
Philip Wadler. Advanced Functional Programming (1995).
Introduces monads as program structuring technique.Paper (Springer)
What we talk about when we talk about monads
Tomas Petricek. Programming Journal, 2018.
A survey paper about monads.Paper (Programming)
Monad Transformers and Modular Interpreters
Sheng Liang, Paul Hudak and Mark Jones. POPL (1995).
Introduces monad transformers.Paper (ACM)
Generalizing Monads to Arrows
John Hughes. Science of Computer Programming (2000).
Introduces Arrows. We will likely not read everything in detail.Paper (Elsevier)
Applicative programming with Effects
Connor McBride, Ross Paterson. Journal of Functional Programming (2008).
Introduces applicatives / idioms.Paper (JFP)
Freer monads, more extensible effects
Oleg Kiselyov and Hiromi Ishii. Proc. of Haskell Symposium (2015).
Introduces free monads in multiple variations.Paper (ACM)
Type directed compilation of row-typed algebraic effects
Daan Leijen. Symposium on Principles of Programming Languages (2017).
We read Sections 1, 2 which show how to program with algebraic effects handlers, and section 4 for the semantics. Section 4 should be understood as a reference, not as an introduction.Paper (ACM)
Effects as Capabilities: Effect Handlers and Lightweight Effect Polymorphism
Jonathan Brachthäuser, Philipp Schuster, Klaus Ostermann. OOPSLA (2020)
Effects as capabilities and contextual reading. We will read sections 1, 2 and 4.Paper (ACM)
Programming with Implicit Values, Functions, and Control (or, Implicit Functions: Dynamic Binding with Lexical Scoping)
Jonathan Brachthäuser, Daan Leijen. MSR-TR-2019-7
We read Sections 1 and 2.Paper (Microsoft Research)
Algebraic Effects and Effect Handlers for Idioms and Arrows
Sam Lindley. Workshop on Generic Programming (2014).
We focus on Sections 1, 2, and 6. Note, that for 6 it is necessary to have (at least) a basic understanding of 3-5.Paper (ACM)
Other Related Papers
Monadic Parsing in Haskell
Graham Hutton, Erik Meijer. Journal of Functional Programming (1998).
Uses monads to write parsersPaper (JFP)
Matthew Pickering, Jeremy Gibbons and Nicholas Wu. Programming Journal (2017).
Uses arrow like structures to express optics, like lensesPaper (Programming)
Arrows, Robots, and Functional Reactive Programming
Paul Hudak, Antony Courtney, Henrik Nilsson and John Peterson. In: Advanced Functional Programming (AFP): 4th International School, 2002.
Shows how arrows can be used in functional reactive programming to program a robotPaper (Springer)
The Essence of the Iterator Pattern
Jeremy Gibbons and Bruno Oliveira. Journal of Functional Programming (2009).
Shows that applicatives capture the essence of iteratorsPaper (JFP)
Monoids: Theme and Variations (Functional Pearl)
Brent Yorgey. Haskell Symposium (2012).
Shows how to construct a library for diagrams using monoidsPaper (ACM)
An idiom's guide to formlets
Ezra Cooper, Sam Lindley, Philip Wadler and Jeremy Yallop. Technical Report (2008)
Uses idioms to model forms on webpagesPaper (PDF)
The F# Computation Expression Zoo
Tomas Petricek and Don Syme. PADL (2014).
Introduces notation for monadics, applicatives and more in F#Paper (PDF)
Idioms are Oblivious, Arrows are Meticulous, Monads are Promiscuous
Sam Lindley, Philip Wadler and Jeremy Yallop. Mathematically Structured Functional Programming (2008).
Shows that idioms embed into arrows and arrows embed into monads.Paper (Elsevier)