CS795: Functional Programming


Below the content of the 2020 course. Evaluation will stay the same for 2021, i.e. 3 projects of which one is an individual project, and a final practical exam, each counting 25% towards the final mark. If time permits, I might include some discussion and assignments on Scala and Clojure in the 2021 course (in addition to the focus on Haskell).

Lecture Times

To be announced.

Course evaluation

Three assignments (two individual and one as a group project) and a practical test (25% each), no subminimum.


  1. Pancake Sorting
  2. In this assignment only the standard prelude should be used, i.e. no third party libraries. Use the Stack test suite (which makes use of HSpec) which will display what the tests are testing (and thus we will know whether some condition is met) e.g.
        spec :: Spec
        spec = do
           describe "isSorted" $ do
           it "handles empty lists" $ isSorted [] `shouldBe` (True :: Bool)
    In terms of time, HSpec can be run with a command line arg to show CPU time, but I will not be too pedantic in terms of precise time measurements. For optFlipSequence, testing should be done on all m! lists of length m where m <= n and n is the length of the lists used for testing the other functions (since to determine optFlipSequence will computationally expensive).
  3. Functional Web Development
  4. Regex Derivatives

Week 1

See SunLearn (rw795) for lecture recordings. Have look at Stack and Cabal and how to set up a Haskell development environment for your particular platform. Most of the content in my lectures will be from the book Programming in Haskell, 2nd Edition, Graham Hutton. For week 1, read the first two chapters in the book by Graham Hutton, and do exercises 3, 4 and 5 at the end of Chapter 2 - this is just to check your own understanding. Slides - these are the slides used in lectures. Also read Chapter 1 in Write Yourself a Scheme in 48 Hours - An Introduction to Haskell through Example and do the 3 exercises (not to be handed in) at the end of Chapter 1.

Week 2

Read chapters 3 and 4 in the book by Graham Hutton. Do the 5 exercises at the end of Chapter 3 and exercises 7 and 8 at the end of Chapter 4. As will always be the case, there are lecture recording for week 2 on SunLearn. Although not required to watch, I can recommend the GoogleTechTalks Haskell 101 and Haskell 102 by Antoine Leblanc. There is also a Github repository with resources related to these two talks.

Week 3

Read Chapters 5 and 6. Although Monday is a public holiday, work on the following problems and post solutions on MS Teams - I might only comment on Tuesday.
  1. Implement your own versions of fold and fold' (i.e. the strict version of foldl). It is enough to implement versions that work on Lists, instead of on Foldable types.
  2. Exercises 6-9 at the end of Chapter 5

Week 4

Read Chapter 7 (and watch the corresponding video lecture on SunLearn). In the Monday lecture we will discuss assignment 1. Also modify the code discussed in the video lecture w.r.t. the Luhn checksum by not reversing xs in the function luhn_sum and also summing over the list of digits (representing the number for which the validity of the checksum digit is verified) after applying altMap by using nSum += d / 10 and nSum += d % 10 (as is done in the Java implementation at geeksforgeeks), instead of using the current function luhn_sub. Also suggest other improvemets to my current implementation of the Luhn checksum.

Week 5

Read Chapter 8 (and watch the corresponding video lecture on SunLearn). Look at the following exercises at the end of Chapter 8: 1, 3, 8.

Week 6

Read Chapter 15 (and watch the corresponding video lecture on SunLearn). Look at the following exercises at the end of Chapter 15: 5, 6. Select groups (size 3 or 4) for assignment 2. Send and e-mail to brinkvdm at gmail dot com with a document containing the following information: Group members and a description of the selected project for assignment 2 (and other information deemed relevant).

Week 7

Read Chapter 9 and work on exercise 6 at the end of Ch 9. Watch the video lectures under Weeks 7, 8 and 9 on SunLearn.

Week 8

Watch the video lecture on functional parsers, listed under week 10, on SunLearn.

Week 9

Watch the video lecture on SunLearn on how to create your own Monadic Either type. We will also continue with presentations for the 2nd project as scheduled on MS Teams.

Week 10 -> end of semester

A collection of video discussions wil be posted on SunLearn on some of the posts at Monday Morning Haskell.

Books and other relevant links and resources

Why should you take this course

Functional programming is a style of programming in which the primary method of computation is the application of functions to arguments. It offers a compact notation for writing programs, powerful abstraction methods for structuring programs, and a simple mathematical basis that supports reasoning about programs. Functional languages represent the leading edge of programming language design, and the primary setting in which new programming concepts are introduced and studied.