Course Description
Expected Background
This is an advanced course in functional programming. To take this course, you should be familiar with the basics of strongly typed functional programming in Haskell, including algebraic data types, pattern matching, and recursion.
If your Haskell is a bit rusty, you should plan to invest some extra effort in the first few weeks. There are several tutorials and other Haskell resources provided from the Haskell Links and Resources page.
Course Philosophy
During this course, we will strive for elegance in our functional programs. A great functional program doesn’t just get the job done; it elucidates the structure of the problem and of its solutions. Often this insight, rather than the program output, is the motivation for writing a functional program in the first place.
Elegant programs aren’t simply written, but crafted through an iterative process of refactoring. This is a skill that must be developed through practice and constructive feedback.
To this end, throughout the course we will use the “workshop” strategy of peer-critiquing, popular in creative writing circles. This will give you the chance to discuss design decisions with your classmates, to think critically about programs that you didn’t write (which can help with objectivity), and to receive deep and timely feedback on your own programs.
Throughout the term (more concentrated at the beginning) you will complete and workshop several small functional programming assignments, called “Hasklets”. Later in the term, you will share and workshop code for your final project.
Planned Topics
Below is a list of topics I plan to cover in the class. However, there is some room for flexibility in this list. We may adapt the content during the course to accommodate student interests, or to give more time to the topics that will be most useful in your projects. If you don’t see something here you were hoping would be covered, speak up!
If some (or even most) of the terms below don’t mean anything to you yet, don’t worry–that’s why you’re in the class!
Planned topics:
- Equational reasoning
- Type-directed programming
- Refactoring functional programs
- Applications of higher-order functions
- Lazy evaluation
- Type classes
- Functors, monads, and monad transformers
- Managing effects (with monads)
- Phantom types
- Generalized algebraic data types
- Purely functional data structures
- “Free” monoids and monads
- The expression problem and modular extensibility
Because this is a programming languages class, we will especially focus on how many of the above features can be applied to implementing programming languages in a strongly typed, functional setting.
Learning Objectives
At the end of this course, students should be able to:
- Prove that two expressions are equivalent using equational reasoning.
- Refactor a functional program to remove redundancy, improve clarity, and support reuse.
- Evaluate the extensibility of a functional program.
- Design and implement a grammar with naming using higher-order abstract syntax.
- Design and implement a typed grammar using phantom types and/or GADTs.
- Apply the functor and monad patterns in the implementation of an interpreter.
- Apply functional data structures in the implementation of functional programs.
- Describe the evaluation of a functional program in terms of graph reduction.