How I Teach Functional Programming
J. Waldmann, March 9, 2017; update July 3
I teach a required course “advanced programming techniques” that contains an introduction to Functional Programming (using Haskell) as well as on overview of techniques from functional programming in other paradigms (like object orientation - OO) and languages (like C#, Java).
In this course, I present (in this order)
- Data (terms, trees, algebraic data types,
data
)
- (first order) Programs (term rewriting, pattern matching,
case
)
- Polymorphism (type constructors)
- (higher order) Programs (lambda calculus, lambda expressions)
- Recursion Schemes (folds - for trees, lists (yes), Peano numbers)
- OO simulation of algebraic data types (the “composite” design pattern)
- OO simulation of recursion schemes (the “visitor” design pattern)
- Restricted Polymorphism (Haskell type classes vs. Java interfaces)
- Lazy evaluation (streams) and its OO simulation (the “iterator” design pattern)
- Higher order functions for stream processing (in Haskell, LINQ, java.util.streams)
- functional reactive programming (vs. the OO “observer” pattern) (since 2017)
Students solve online exercises (try them here) via the Leipzig autotool system.
The slides for the course are here: 2016, 2017.
(Related: on avoiding built-in data types, in particular, lists.)
This course fits in our curriculum for Bachelor students in computer science, which contains these courses (among others)
- 1st term: introduction to discrete mathematics and logics, to computation and programming
- 2nd term: algorithms and data structures
- 3rd term: software engineering
- 4th term: advanced programming techniques (my course), software engineering project work
- 5th term: language concepts for parallel and concurrent programming
Here I only mentioned courses with a direct relation to programming. Here is the full curriculum.