Department of Computer Science
Lund University

Functional Programming

EDA120/DATE13 - 2009






Introduction

With mainstream programming languages we understand programs by understanding how the computer sequentially executes the program. Functional programming represents a different approach to programming. By interpreting variables in the mathematical sense the program semantics can be understood by simple rewrite rules. Higher order functions become natural building blocks, and you can work with infinite data structures. As a consequence, programs can be made much shorter and easier to understand. The importance of functional programming is further elaborated in the essay Why functional programming matters.

This course aims to make functional techniques and thought patterns part of your programming repertoire. In order to establish these skills the course emphasizes practical programming exercises using the functional language Haskell. Not only do they exercise programming with a more mathematical mindset, they also demonstrate how functional programming can be used in some practical applications.


Prerequisites

LTH EDA027
NatFak    DATA01

Additional recommendation: Mathematics 15p (25hp)

Course structure

During the first week and a half of the course you will make a quick tour of the Haskell language, primarily by completing the self-study course Two dozen short lessons in Haskell. These exercises will be supported by two lectures in the first week.

Then the main part of the course begins. It consists of four large programming assignments. Each assignment and the problem area it illustrates will be presented at a dedicated lecture. You may do the self-study course and the assignments either at school or at home.

A number of lectures will be given throughout the course on topics needing a more in-depth treatment.

The estimated time required to complete this course is allocated as follows:

Lectures 22 h
Self studies 130 h

Assignments

The programming assignments are listed below together with their deadlines. Two of the assignments are to be completed individually and two should be completed in pairs.

1 Chatterbots 10/11 Pair
2 Functional music 22/11 Pair
3 String alignment 29/11 Individual
4 Functional parsing 14/12 Individual

Examination

To pass on this course you need to have all four assignments approved. Deadlines are strict in the sense that solutions which are handed in too late will be disregarded unless an agreement has been made in advance with a teacher. Obviously inadequate solutions will also fail immediately.

With all assignments approved you will receive grade three on the course. If you want a higher grade, there will be an optional written exam at the end of the course. Here is an example of what the exam might look like, and the corresponding suggested answers. Other old exams are here, here, here, here, here, here, here, and here. Some more older English versions are here, here, here, here, and here.

The written exam will take place at 14-19, December 17 in room MA10. Note that registration is required at least one week in advance. You should be aware that there is no makeup exam for this course.


Programming environment

For all programming exercises and assignments you will use GHCi, the interpreter part of the Glasgow Haskell Compiler system. You will need to access the user manual.

You can install and GHCi on your own computer from here. Test your installation by creating a new file Test.hs containing the code

module Main where	 
main = putStrLn "Hello, world!"
Open the file and type main at the GHCi prompt. You should get the response "Hello, world!".

To use GHCi on the EFD systems:

You may note that EFD version of GHCi for the course is not the latest one. But that does not matter for your work in this course.

Editing Haskell files can be done by any text editor. For those favouring Emacs there is a haskell-mode which automatically handles indentation and syntax colouring. There is also a syntax-file for the Vim editor.


News feed

Notices from teachers will be posted on this rss feed. Make sure you subscribe to it or check it regularly. Any questions should be sent by mail to the course teacher.


Literature and online resources


Teachers


Teaching locations

Mondays 13-15 E:C
Wednesdays 13-15 E:C

Schedule

Week Lectures Deadlines
1 26/10
28/10
L1: Introduction
L2: Language overview
2 2/11
4/11
L3: The standard prelude
L4: Presentation of assignment 1

self-study course completed
3 9/11
11/11

L5: Presentation of assignment 2

assignment 1 due 10/11
4 16/11
18/11
L6: Types and classes revisited
5 23/11
25/11
L7: Presentation of assignment 3
L8: Monads revisited
assignment 2 due 22/11
6 30/11
2/12
cancelled
L9: Presentation of assignment 4
assignment 3 due 29/11
7 7/12
9/12



17/12
L10: Functional reactive programming
L11: FP with mainstream languages
and Concluding Q&A session


Optional written exam

assignment 4 due 14/12