Latest change May 9, 2006

To avoid spam, all mail addresses on this page have the "@" replaced by "#".

CD 5100 Functional Programming, Fall 2005 (Period 1)

Latest News

06-05-09: Next exam takes place 2006-08-17. You can signup online.

General Information

Functional Programming is a B level course in Computer Science (datalogi) that is given by Dept. of Computer Science and Electronics (IDE) at Mälardalen University. It yields 5 credits.

Official information about the course (in Swedish), including the course plan.

Teachers

Course leader: Björn Lisper
Email: bjorn.lisper#mdh.se
Phone (MdH): 021-151709
Office: room U3-120, IDE (Rosenhill, 3nd floor, where Komvux used to be).

I'm best reached via email. When the department is open you can feel free to drop in if I'm in office (I'll simply throw you out if I'm busy), but often I'm out on different missions.

Course and Lab assistant: Jan Gustafsson
Email:Jan.Gustafsson#mdh.se
Phone (MdH): 021-101462
Office: room U3-122

Mailing List

Since there seems to be no interest for a mailing list for the course, I have decided not to set up such a list this year. Information about the course will thus be disseminated only through this web page, and at lectures.

Schedule

The course takes place in period 1 (lectures etc. taking place weeks 34-39). There is a schedule for lectures and laborations, which also indicates when I will bring up different topics. See also the official schedule.

Course Contents

The purpose of this course is to give the students a solid understanding of functional programming, its applications, and its strengths and weaknesses. This includes knowledge of recursion, advanced data structures, modern type systems, higher order functions, lazy vs. eager evaluation, the importance of freedom of side effects, how to regain stateful (imperative-like) programming while retaining freeedom of side effects, and more. We will also give short orientations of lambda calculus and type inference, in order to enhance the understanding of the functional programming paradigm.

In order to reach these goals, the course will be based on the functional programming language Haskell. This language represents state-of-the-art in functional languages, and learning it thoroughly will give you good knowledge of all the things mentioned above. It will also show how powerful the functional programming paradigm can be from a software engineering point of view - this paradigm provides, arguably, the best support for writing concise, reusable, and safe programs.

How to Follow this Course

It is recommended that you read the part in the literature that will be covered before the lecture, see the detailed schedule. Thus, you will be able to get more out of the lecture.

Don't be afraid to be active during the lectures. The dumbest questions are the ones never posed.

Examination

There will be laborations (LAB1, 1p), a written exam (TEN1, 3p) and a small programming project (PRO1, 1p). To get a pass on the course, one needs to pass all these examination moments. The grade (3-4-5) is based on the grade for the the written exam. Completed laborations and project before the first exam gives five bonus points at the first written exam (at the end of period 1).

Oldtimers from 2001 and earlier: the contents of the course has changed a bit since you followed it. We offered three written examinations for you during 2003/04. No more special examination will be given for you, but you will have to take the ordinary exam for the new version of the course.

Laborations

There will be four laborations, see the schedule. You will typically do the laborations in groups of two. Signup forms for the laborations will be posted outside the laboration halls. The laborations are in Haskell, and the two last laborations use the Haskell Graphics Library for interactive animations in Haskell.

Lab 1, getting started.

Lab 2, a little bit more advanced.

Lab 3, where you are supposed to do a little animation.

Lab 4, where you are supposed to do some very rudimentary natural language processing.

The scheduled laborations will take place in halls with Windows-equipped PC's. We will set up the Haskell interpreter Hugs on these machines, under Windows, but you are free to use any other environment and Haskell implementation if you want. (However, the Haskell Graphics Library has to be supported.) With Hugs and a text editor like emacs (or any other of your choice), you can develop programs by editing the Haskell code in the text editor and loading and testing them in Hugs. See our Getting Started guide.

The software needed is available also for Linux, see further below. (The generic Unix source based distribution of SOEGraphics seems to build and work fine on Mandrake 10.0 systems.)

Here are some Emacs Tutorials, in case you want to use emacs and are unfamiliar with it. There is also a Haskell mode for Emacs.

You can download implementations of Haskell for your own computer here (however, see below). We do recommend Hugs, which is an interpreter for Haskell. It is easy to install and use, and it provides support for the Haskell Graphics Library (which is found at the Hugs site).

Note: For some of the laborations you need the SOEGraphics library. The simplest way to get this is to download a special distribution of Hugs, including SOEGraphics, from the software download page for the course book. This distribution also the contains the Haskell source code for SOEGraphics and the other modules in the course book, as well as GraphicsLib.

Project

There will also be a programming project, where you are given a problem to solve using functional programming techniques. The project will take place towards the end of the course, and we will try to design it so the the workload corresponds to one manweek per person. The idea is that you work with the project quite independently, but we will provide advising.

There are some suggested projects to choose from. However, you can also suggest your own projects. In this case you should write your own specification of the project and give to us. We will then judge it, possibly suggest modifications, and finally decide whether we think it is appropriate or not.

The project is done in groups of at most two persons. Two is the preferred size of the project groups, but you can also do a project on your own.

The projects will be examined by email. You should submit the following: the source code, and a short written report (typically 1-2 pages) that briefly describes how you have solved the problem and gives an account for any interesting findings. If you do a project suggested by yourself, then the report should include the project specification. The solution will be judged primarily for correctness, but also for efficiency, clarity, etc. This means, for instance, that a very clumsy solution that works still might require some improvement to pass. The report will also be judged: thus, we might require that a poor report is rewritten before we give a pass on the project.

Submit the source code + report to Jan.Gustafsson#mdh.se.

Examination by email is convenient for both you and us, but there is of course a risk of cheating (mainly that inactive project members benefit from the companion's work). I account on your high moral that this won't happen. Discovered cases of cheating will of course be dealt with in the usual manner.

Written Exam

The written exam is five hours long. Course literature is not allowed at the exam. This also includes all other information that could replace parts or all of the course literature, such as own notes, copies of slides, other books, and such. Computers with Haskell implementations (or any other stored information that could aid the student) are also not allowed. However, "general" aids, that are not specific to Haskell or functional programming, are allowed, such as calculators without any stored information of relevance to the course.

Please note that signup for the exam in advance is mandatory! Signup can be done online.

See also our general information about written exams (in Swedish).

Upcoming Exams

Next exam: 2006-08-17, 8:30-13:30, place not decided yet.

Old Exams

All these documents are in PDF format.

This Year

Wednesday 06-01-11, 8:30-13:30, Kopparlunden: exam, and suggested solutions

Wednesday 05-10-26, 8:30-13:30, Kopparlunden: exam, and suggested solutions

Last Year

Wednesday 04-10-27, 8:30-13:30, Kopparlunden: exam, and suggested solutions

Wednesday 05-01-19, 8:30-13:30, Kopparlunden: exam, and suggested solutions

Wednesday 05-08-03, 8:30-13:30: exam, and suggested solutions

Previous Years

Tuesday 02-10-29: exam, suggested solutions, and my comments to the exam. Also translated into English: exam, and suggested solutions.

Tuesday 03-01-07: exam and suggested solutions.

Wednesday 03-10-29, 8:30-13:30, Kopparlunden: exam, and suggested solutions. Also translated into English: exam, and suggested solutions.

Friday 04-01-09, 8:30-13:30, Kopparlunden: exam, and suggested solutions. Also translated into English: exam, and suggested solutions.

Friday 04-08-13, 9:30-14:30, IDt: exam, and suggested solutions. (No English version exists of this exam.)

Literature

Paul Hudak: The Haskell School of Expression: Learning Functional Programming through Multimedia, Cambridge University Press, New York, 2000, 416 pages, paperback ISBN: 0521644089, Hardback ISBN: 0521643384

The book is available at Studentbokhandeln. Price SEK 349 (2004, I don't know the exact price this year yet).

A list of known errors in the book.

Directions for reading: what parts of the literature are of relevance for the written exam.

If you want to know all the details of Haskell, here's the online Haskell report.

Recommended (Optional) Literature

Another good textbook is Simon Thompson: Haskell: The Craft of Functional Programming, Second Edition, Addison-Wesley, 507 pages, paperback, 1999. ISBN 0-201-34275-8.

A third alternative is Manuel Chakravarty, Gabrielle Keller: An Introduction to Computing with Haskell, Pearson Education, 2002. ISBN 1-74009-404-2.

Also see the Haskell Bookshelf.

Extra Course Material

Material for lecture 15: MapReduce, and Erlang. Here is a Haskell implementation of the MapReduce model.

A Brief Survey of Functional Programming Languages: an attempt to give you some context.

All slides for the course in 4-up.

A set of exercises.

Graphics Library Documentation. (Good if you want to know the details of the Graphics library.)

FAQ (Frequently Asked Questions) for the course.

Links

Serious

Learning Haskell.

Haskell 98 Online Reference.

Arjan van Ijzendoorn's Tour of the Haskell Syntax.

Overview of Haskell's Standard List Functions (courtesy of John Hughes, Chalmers).

Simon Thompson's list of common Hugs errors with explanations.

Some Haskell links with more reading.

Frequently Asked Questions for comp.lang.functional.

Typetool, on online type inference service. You give it a simple functional program (lambda-expression), and it will infer the most general type for it and show you how it was derived (or tell why it failed).

Yampa, the most recent Haskell system from Yale for functional reactive programming. (The FAL library in the book is an example of such a system.)

The Wikipedia Entry on Functional Programming.

Workshop on Functional and Declarative Programming in Education (FDPE02).

Google uses a functional programming model to specify much of their data processing.

Erlang is a functional language, extended with process-parallelism, which is extensively used in real applications.

Galois Connections, Inc. uses functional programming languages in their projects.

Not so Serious

The Evolution of a Haskell Programmer, or how to write the factorial function...

The infamous Lambda Dance.

How to Get Through this Course Easily :-)

How not to Code Your Project/Laboration Solutions

Thesis Projects (exjobb)

I can offer some Haskell-related thesis projects (exjobb). We cannot pay for them, but on the other side we have freedom to tailor them to become maximally interesting! Feel free to come by my office and discuss if you are interested. I have defined two projects for the moment, see below, but it is certainly possible to define other projects if some interesting ideas pop up.

Course Evaluation

The course evaluation is closed. Here is the compiled summary of your answers. My course analysis is to some extent based on the evaluation.

Earlier Versions of the Course


Viewable With Any Browser

Björn Lisper
bjorn.lisper#mdh.se