Applied Deliberation

Assorted Adventures of Sampsa Kiiskinen

TIES341 Functional Programming 2, 1–5 ECTS

This is the course plan drafted on 2019-10-25 and finalized on 2019-11-13.

Introduction

Welcome to an advanced course on functional programming. On this course, we will use the Haskell programming language to explore such things as

This course serves as a guided tour through some of the most interesting parts of the Haskell ecosystem. As such, the goal of this course is not to train you to become a Haskell programmer, but rather to refine your skills in abstract thinking and expose you to new ideas that might be of use elsewhere.

Prerequisites

Completing this course requires a bit of mathematical maturity and a good grasp of the basics of Haskell. Thus, you should be familiar with what the following courses offer.

Code Name
TIEA341 Functional Programming 1

Familiarity with the following courses is also helpful for being able to appreciate the things we explore in a broader context.

Code Name
MATA140 Introduction to Discrete Mathematics
MATA150 Logic
TIEA241 Automatons and Formal Languages
TIES448 Compiler Technology
TIES542 Principles of Programming Languages

As always, the lack of familiarity can be compensated with time and motivation.

Materials

The main material for this course is handed out by need. If you feel like you need supplementary material, you are free to pick your poison from a plethora of existing Haskell books [1].

Schedule

This course begins with an introductory lecture on 2019-10-28 12:15 (local time, whatever that may be), features three consecutive classroom activities per week and ends by 2019-12-24 00:00. The classroom activities feature the following events.

Date Weekday Subject
2019-10-28 Monday Opening Ceremony, Type Classes, Monoids
2019-11-04 Monday Functors, Contravariant Functors, Bifunctors, Profunctors
2019-11-11 Monday Applicative Functors, Alternative Functors, Context-Free Parser
2019-11-18 Monday Monads, Numerics, Context-Sensitive Parser
2019-11-25 Monday Foldables, Traversables, Monad Transformers, HTTP Client
2019-12-02 Monday Isomorphisms, Algebra of Types
2019-12-09 Monday Fixed Points, Recursion Schemes, Peephole Optimizer
2019-12-16 Monday Zippers, Calculus of Types, Topics of Your Choice

At the beginning of each week, a set of exercises is assigned. Each set must be done before the next set is assigned, so there is exactly one week of time to do each one.

You may personally negotiate later deadlines, but this is generally not a good idea, because catching up is really difficult. Ideally, we would not have any deadlines at all, but experience suggests that they really improve outcomes.

Classroom Activities

The classroom activities on this course are primarily exercise sessions, where you can do exercises together and get guidance from an instructor. The first activity of the day may turn into a lecture, in case general questions arise or I happen to have some interesting stories to tell, but the remaining time is always reserved for exercises. Participation is voluntary, but strongly encouraged.

The activities should take place in a computer classroom, but it is a good idea to bring your own laptop regardless.

Exercises, Grades and Credits

Exercises are graded from zero to three stars, so that you get

The scale is obviously nonlinear, but this is balanced out by the fact that there is a limited supply of exercises.

Your grade \(\measuredangle\) is simply determined by feeding the number of stars \(\star\) you have gotten from exercises to the projection function \(\pi\), which is defined according to

\[\begin{eqnarray} {\star} & : & \mathcal U \\ {\star} & = & \{n : \mathbb N \mid n \le 72\} \\ {\measuredangle} & : & \mathcal U \\ {\measuredangle} & = & \{n : \mathbb N \mid n \le 5\} \\ \pi & : & {\star} \to {\measuredangle} \\ \pi (n) & = & \begin{cases} 0, & \phantom 00 \le n \le 36 \\ 1, & 37 \le n \le 43 \\ 2, & 44 \le n \le 50 \\ 3, & 51 \le n \le 57 \\ 4, & 58 \le n \le 64 \\ 5, & 65 \le n \le 72. \end{cases} \end{eqnarray}\]

I reserve the right to transparently hand out extra stars for pointing out mistakes in the material or being helpful in other ways.

Visualization of \pi
Visualization of \(\pi\)

Summative and Formative Assessment

I will grade your solutions within one month of you handing them in (see the section on completing the course for details).

Time permitting, I will also look over your solutions and provide feedback. The feedback will not affect your grade, unless your solutions are obviously plagiarized. If you happen to copy someone else’s answer, be honest about it and explain what lead you to do so and what you learned from it. As long as this does not happen too frequently, it will not be considered plagiarism.

Tests or Examinations

There is no written test, but there is a brief oral test at the end of the course. The oral test consists of one question and its sole purpose is to ensure that you did not blindly copy your solutions from the Internet. It is not graded, but it can be failed (with a dedicated lack of effort).

If you have a pressing reason that prevents you from doing the exercises or taking the oral test, you may personally negotiate a written test, but this is not going to be easier for you or the instructors.

Completing the Course

The following instructions explain how to complete this course, in as much detail as possible.

Returning Files

If you send me an archive, package the files instead of the directories and name the archive according to your university username.

To create a Gzip archive, you can use the following command.

$ tar -czf sapekiis.tar.gz Exercise1.hs Exercise2.hs

Make sure to check that you did not accidentally package your animes, because I do not want to see that garbage.

$ tar -tf sapekiis.tar.gz

To create a ZIP archive, you can use either of the following commands.

$ rm -f sapekiis.zip && zip -9q sapekiis.zip Exercise1.hs Exercise2.hs
$ jar -Mcf sapekiis.zip Exercise1.hs Exercise2.hs

Checking the packaging works analogously.

$ unzip -l sapekiis.zip
$ jar -tf sapekiis.zip

Making a public Git repository is a bit more involved, but can be done on the university network as follows.

Let us first create a remote repository with a random name.

$ ssh sapekiis@charra.it.jyu.fi
$ cd /autowebhome/home/sapekiis/public_html
$ echo "$(echo "$RANDOM" | sha256sum | head -c 6).git"
abcdef
$ mkdir abcdef
$ cd abcdef
$ git init --bare
Initialized empty Git repository in /autowebhome/home/sapekiis/public_html/abcdef/
$ mv hooks/post-update.sample hooks/post-update
$ git update-server-info
$ exit

Let us then create a local counterpart of the same repository.

$ cd
$ mkdir ties341
$ cd ties341
$ git init
Initialized empty Git repository in /home/sapekiis/ties341/.git/
$ mkdir Week1
$ cd Week1
$ touch Exercise1.hs Exercise2.hs
$ cd ..
$ git add Week1
$ git commit -m "Did week 1 exercises 1 and 2."
[master (root-commit) defaced] Did week 1 exercises 1 and 2.
  2 files changed, 0 insertions(+), 0 deletions(-)
  create mode 100644 Week1/Exercise1.hs
  create mode 100644 Week1/Exercise2.hs
$ git push --set-upstream \
  sapekiis@charra.it.jyu.fi:/autowebhome/home/sapekiis/public_html/abcdef.git \
  master
Counting objects: 3, done.
Writing objects: 100% (20/20), 420 bytes | 0 bytes/s, done.
Total 20 (delta 0), reused 0 (delta 0)
To sapekiis@charra.it.jyu.fi:/autowebhome/home/sapekiis/public_html/abcdef.git
  * [new branch]      master -> master
Branch master set up to track remote branch master from
sapekiis@charra.it.jyu.fi:/autowebhome/home/sapekiis/public_html/abcdef.git.

Anyone can now clone the repository as follows.

$ cd /tmp
$ git clone http://users.jyu.fi/~sapekiis/abcdef.git
Cloning into 'abcdef'...
Checking connectivity... done.
$ cd abcdef
$ git ls-files
Week1/Exercise1.hs
Week1/Exercise2.hs

While Git is the best way to do and return your solutions, I would recommend against using it if you do not know how to do so properly.

Transcripts

There exist

but expect these links to move in the near future.

[1] HaskellWiki, “Books,” 28-Oct-2019. [Online]. Available: https://wiki.haskell.org/Books