CSE301 / CSC_3F001_EP: Functional Programming

Course description

In this course, we will study functional programming, and will learn how to take advantage of the features of modern typed functional programming languages. We will study in depth the notions of algebraic data types, higher-order functions, polymorphism, and side-effects. The practice sessions will be done in Haskell, but concepts presented in the course can be applied in many other languages such as OCaml, SML or Python.

Prerequisites: CSE201 and CSE203

General information

Fall 2024 Schedule:

Instructors:

Labs Lectures Project


Assessment

Your grade is computed based on:

where regularly asking questions during labs or lectures or on the Moodle Q & A forumSlack space will earn you full credit for participation. Attendance at labs is mandatory except for medical reasons or with prior permission. Attendance at lectures is strongly encouraged.

You will receive full or almost-full credit on the formative assignments so long as you make a reasonable attempt at completing them. Collaboration is allowed and encouraged, although you should understand everything that you submit and acknowledge your collaborators. This extends to online forums and tools such as ChatGPT. Remember that the point of the formative assignments is to be formative, i.e., to help you to learn, and learning at times requires grappling with the material.

The main components for determining your course grade are a final exam and a final project. The final exam will be a two-hour exam with both theoretical questions and programming problems, held during the last lab (Lab 7). The final project will require you to write some more significant functional code in a small group of 1-3 people, on a topic that will be introduced later in the semester. The project will be due after the holiday break, and each group will give a brief presentation to be scheduled in November.

Getting up and running with Haskell

The Glasgow Haskell Compiler (GHC) is an open source compiler and interpreter for Haskell. It includes the following programs that may be run from the command line:

Documentation on all of these programs and more is available at the GHC User’s Guide.

GHC 9.6.2 is already installed on the lab machines. You can verify this by running

$ ghc --version

in a terminal. We will be using the interpreter ghci more often than the compiler ghc. You can run it as follows:

$ ghci
GHCi, version 9.6.2: https://www.haskell.org/ghc/  :? for help
Prelude> 

To install GHC for yourself (e.g., on your laptop), the easiest approach may be to use ghcup. In addition to installing GHC, ghcup will also install the Cabal library manager and build system, and optionally Stack, which is a newer tool for developing Haskell projects.

In any case, make sure that you install a stable release of GHC, version 9.6.2 or higher.

You will also need some editor to edit Haskell source files. VS Code is a popular choice, although personally I use Emacs.

Lecture notes, textbooks, and online resources

Whereas labs are designed to provide more practical programming experience, lectures cover the theoretical foundations of functional programming. I will attempt to provide lecture notes reasonably in advance of (or eventually after) the lectures, with the understanding that they may not be an exact transcript of what happened during lecture, and that I reserve the right to modify them at any point to incorporate corrections/improvements/additions. I will also post a copy of any slides that I use, eventually incorporating bug fixes. Of course you are welcome to take your own notes during lectures!

Although there is no course textbook, the following books may be helpful to complement the lectures:

Copies of both books are available on reserve at the Bibliothèque Centrale. (The book webpage for Programming in Haskell also provides links to slides and videos based on Hutton’s Functional Programming course at Nottingham University.)

There are also several good books on Haskell that are freely available online:

You may also find these links useful:

Finally, if you enjoy this course and want to go further, you may be interested in:


Labs


Lectures


Project

This year’s project is about writing a text adventure game on and around trees.