This is a taught course in the School of Informatics suitable for first-year undergraduate students (SCQF level 8). The course teaches the basics of functional programming using the language Haskell. The main goal is to acquaint the student with fundamental programming concepts such as recursion, abstraction, higher-order functions and data types, whilst at the same time emphasizing the practical use of such constructs by applying them within a graphical environment. For further details see the course catalogue entry.

Informatics 1: Functional Programming is part of
Informatics 1,
the first-year programme for all undergraduate degrees in the School of
Informatics. During semester 1, students should also be
taking *Informatics 1:
Computation & Logic*.

Lectures · Exercises · Tutorials · Revision Tutorials · Labs · Online · Feedback · Slides · Books · Haskell · Exams · Videos · Contact · Competition

**Slides and reading:**
Here are the slides and code examples for each lecture.
The pages in the two course textbooks that correspond to each lecture
are indicated.

Week | Subject | Slides (code) | Reading in Thompson / Lipovača |
---|---|---|---|

1. | (No FP this week) | ||

2. | Introduction. Functions. Lists. (Extra FP lecture on Thursday) |
lect01.pdf (Land of Lisp music video, lect01.zip), lect03.pdf (lect03.zip) |
Sects. 1.2-11,1.14; 2.1,2.3,2.4,2.7; 3.1-5,3.7; 5.5,5.6
/ pp. xv-42 except 13-14,18-22,26-33,35-40 |

3. | Lists and Recursion (Extra FP lecture on Thursday) |
lect04.pdf (lect04.zip), lect05.pdf (lect05.zip) | Sects. 4.1,4.2,4.4,4.5,4.7; 5.2; 6.2; 7.1-5; 17.1,17.2,17.6 / pp. 13-14,18-22,35-40,42-45,51-58 |

4. | Map, filter, fold | lect07.pdf (lect07.zip) | Sects. 10.1-4; 11.1-4 / pp. 59-78,80-85 |

5. | (No FP lectures this week) | Catch up on your reading! | |

6. | Class test; lambda, sections | lect08.pdf | Revise for Class Test |

7. | Algebraic data types | lect09.pdf (lect09.zip) |
Sects. 4.3; 5.3; 14.2-4 and p. 99 (naming types)
/ pp. 109-113,117-119,121-122,127-137 |

8. | Abstract types | lect11.pdf (lect11.zip) |
Sects. 15.1,15.2; 16.1,16.2,16.4,16.7,16.8
/ pp. 87-89,104-107,113-114 |

9. | Type classes | lect13.pdf (lect13.zip) | Sects. 13.1-5; 14.6 / pp. 27-33,122-127,138-140,141-143 |

10. | Mock exam; IO and monads | lect15.pdf ("Haskell is useless" discussion, lect15.zip) |
Sects. 8.3-5; 18.4-5
/ pp. 153-162,272-277,280-287,292-296 |

11. | Logic and programs | lect17.pdf, lect18.pdf | Sects. 9.1,9.2,9.5 / these slides |

**Lectures:**
14.10–15.00 Mondays (Appleton Tower, Lecture Theatre 4)
and 11.10–12.00 Tuesdays (Appleton Tower, Lecture Theatre 5)
during Semester 1.
There are extra lectures on Thursday of weeks 2 and 3
(11:10–12:00am, Appleton Tower, Lecture Theatre 4)
and no lectures in weeks 1 and 5.
You are very strongly advised to attend all lectures.

*Links:*
Appleton Tower
(Map);
Lecture Theatre 4;
Lecture Theatre 5.

**Exercises:** Tutorial exercises are
published here at least a week before the corresponding tutorial.
This work does not contribute towards your mark for the course but it is
* absolutely essential* for your understanding of the material.

You can discuss your work on these exercises with other students, and ask questions on the discussion forum. If you are having difficulties, drop in to the lab. Or go to InfBase, the Informatics student help desk.

- Week 2, Lab : Lab code : Lab instructions : (solutions)
- Week 3, Tutorial 1 : Comprehension and Recursion : (solutions)
- Week 4, Tutorial 2 : The Caesar Cipher : (solutions)
- Week 5, Tutorial 3 : Higher-order Functions : (solutions)
- Week 6, Tutorial 4 : Screen-scraping : (solutions)
- Week 7, Tutorial 5 : Logic : (solutions)
- Week 8, Tutorial 6 : The Barcode Reader : (solutions)
- Week 9, Tutorial 7 : Turtle Graphics and L-systems : (solutions)
- Week 10: Mock exam, no tutorial
- Week 11, Tutorial 8 : Finite State Machines : (solutions)

**Tutorials:** These start in week 3 and
take place each week until the end of semester, except for week 10.
If you are ill or otherwise unable to attend one week then email your
tutor, and if possible attend another tutorial group in the same week.

*Link:* Tutorial group times, places and membership.

If you wish to move to a different tutorial group, please * ask the ITO*
through their online
contact form and explain your constraints.
Or visit them on level 4 of Appleton Tower.

Students are expected to prepare for each tutorial, which includes completing the tutorial exercises and the reading.

*You must attempt the work before the tutorial and bring with you
a printout of the work you have done. Tutorials are mandatory, and the
only way to learn is to do the work before the tutorial, not at the tutorial.
Students who have not done the work in advance will be sent away.*

**Revision Tutorials:**
There will be extra drop-in tutorials
starting in week 4 for students who find that they require extra help.
This is * in addition to* and

- 1-2pm on Mondays in AT5.07
- 2-3pm on Wednesdays in Computer Lab West (AT5.05)

- Week 4 Revision Tutorial exercises: 2012 class test (solutions)
- Week 5 Revision Tutorial exercises: 2011 class test (solutions)
- Week 6 Revision Tutorial exercises:
2010 class test (solutions)

[The solution to 1a is wrong - it should return an error for non-letters.] - Week 7 Revision Tutorial: exercise (solutions)
- Week 8 Revision Tutorial: exercise (solutions)
- Week 9 Revision Tutorial: exercise (solutions)
- Week 10: Mock exam, no Revision Tutorial
- Week 11 Revision Tutorial: exercise, template file (solutions)
- Week 12 Revision Tutorial: exercise (solutions)
- Week 13 Revision Tutorial: 2012 final exam
- Week 14 Revision Tutorial: 2012 final exam

**Labs:** Computer Lab West (CLW)
in Appleton Tower room 5.05
is reserved for Inf1-FP for a few hours every weekday.
A lab demonstrator will be available at the times indicated to assist
with the coursework.

Reserved for Inf1-FP | Demonstrator available | Location | ||

Mondays | 3:00–5:00pm | 3:00–4:00pm | CLW | |

Tuesdays | 2:00–5:00pm | 3:00–4:00pm | CLW | |

Wednesdays | 2:00–5:00pm | 3:00–4:00pm | CLW | |

Thursdays | 2:00–5:00pm | 3:00–4:00pm | CLW | |

Fridays | 3:00–5:00pm | 3:00–4:00pm | CLW |

After week 2, the labs are run on a drop-in basis and you can go as often as you like.

**Online:** Online sources of help include:

- Some of the Inf1 tutors provide help in the Inf1 IRC chatroom (see Kit Barnes's guide to IRC).
- Discussion
forum: You can post questions and answers on anything related to
Informatics 1 courses. The course lecturers, teaching assistants and
tutors will also read and answer questions.
*Warning:*Please read this page if you have problems viewing or commenting on the discussion forum.

**Feedback** will be provided on all of your work, with the
exception of the final exam.

- Tutorial exercises ("formative"): feedback is given orally on your attempts at tutorial exercises during your tutorial.
- Class test: this will be marked and returned to you in your tutorial in week 7. The numerical scores are accompanied by brief written feedback in cases where your solution is deficient.
- Mock exam ("formative"): this will be marked by computer and the result returned to you during week 11 as an approximate indication of your performance. (The final exam will be marked by a human, using this automated testing as the starting point.)

**Books:**
You will need * one* of the following textbooks:

- Simon Thompson. Haskell: The Craft of Functional Programming, Third Edition. Addison-Wesley, 2011. Solid academic-style textbook with careful explanations.
- Miran Lipovača. Learn You a Haskell for Great Good! No Starch Press, 2011. Informal and fun, but requiring some previous programming background. Adequate for this course but not including all topics covered in the lectures. Available on-line. (Unless you buy the book, you will need this table of contents with page numbering.)

Section/page references in both books that correspond roughly to the lectures
are given above. Read * at least* these.
It would be better to read more than these pages, to get the context
and to understand related concepts. If you find a topic in one of the
books hard to understand, try the other one.

All of the following books were also written for beginning students, and may provide a useful alternative perspective.

- Graham Hutton. Programming in Haskell. Cambridge University Press, 2007. Concise and elegant, a bit more formal in its development than Thompson.
- Paul Hudak. The Haskell School of Expression. Cambridge University Press, 2000. Uses multimedia to demonstrate Haskell programming.
- Richard Bird. Introduction to Functional Programming using Haskell, Second Edition. Prentice Hall, 1998. This is more advanced than Thompson and best suited to students with a good background in mathematics.
- Bryan O'Sullivan, John Goerzen and Don Stewart. Real World Haskell. O'Reilly, 2008. An introductory textbook with a practical angle of approach, and available on-line.
- Rex Page. Two Dozen Short Lessons in Haskell (online copy). University of Oklahoma, 1997. Requires active participation from the reader.

**Haskell**

- If you are using your own machine, we recommend that you download and install the "Haskell Platform" from here. A message from a student explaining how to overcome a problem with the current version of Ubuntu is here.
- Instructions about how to install Haskell mode in Emacs are here. Note that it is already installed in Emacs on DICE, but it is not currently installed in Emacs on the open access Windows machines.
- www.haskell.org has everything you could possibly want to know about Haskell, including the definition of the language, a list of books on the subject, links to conferences/workshops, various libraries, and more! Have a look at "A Gentle Introduction to Haskell".
- Documentation of Haskell's predefined functions is in HackageDB, which also includes documentation on the rest of the Haskell library. The library can conveniently be searched using Hoogle.

**Examinations:** Assessment for Inf1-FP is
done through two exams.

- The class test is a 35-minute
hand-written exam held on Monday of week 6 in place of the lecture,**closed-book**. The class test contributes 10% towards the final mark for the course.**in George Square Theatre**

*Link:*class test (solutions) - There is a 2-hour open-book mock programming exam during week 10 as
practice for the final exam; it does not contribute towards the final mark
for the course.
For this,
**you must attend for your allocated session and only that session.**

*Link:*mock exam (solutions) - The final exam is an 2-hour
programming exam held on 20 December in the computer labs in Appleton Tower. It is held in two sittings (9:30–11:30 and 14:30–16:30) and each student is allocated one sitting by the ITO.**open-book**The final exam contributes 90% towards the final mark for the course.**You must attend your allocated sitting and only that sitting.**

*Links:*first sitting (template, solutions); second sitting (template, solutions); resit (template, solutions)

*Links:* past papers;
instructions for programming exam;
allocation of students to * final* exam sittings (revised);
marks and grades;
George Square Theatre
(Map).

**Videos:** Recordings of lectures are available
online.
Please note that these recordings supplement lectures by allowing you to
review the material presented and revise for the exam. They are
not intended as a substitute for attending and participating in the lectures
themselves.

*Links:* Video
recordings of lectures;
some video lectures from Microsoft on Haskell.

**Contact:** The course lecturer is
Don Sannella
and the course teaching assistant is
Chris Banks.
The best time to speak to Don is at the end of a lecture.
If contacting Don or Chris by email please
use your University address.
You can also always ask questions on the
discussion forum.

**Programming Competition:** Each
year the course concludes with a programming competition,
with an actual prize draw and first prize sponsored by software company
Galois. The competition
centers round the drawing of fractal-based images. This provides
students with an excellent opportunity to show off the skills they
have learned during the course, and to set loose their creativity in
an unconstrained environment. Every year students have gone on to
amaze the course organizers—and themselves—with ingenious
and beautiful drawings and fractals, and this year is certainly not
going to be different.

*Links:*
* Entries from 2013*;
2012;
2011;
2010;
2009;
2008;
2007;
2006;
2005.

Informatics Forum, 10 Crichton Street, Edinburgh, EH8 9AB, Scotland, UK
Tel: +44 131 651 5661, Fax: +44 131 651 1426, E-mail: school-office@inf.ed.ac.uk Please contact our webadmin with any comments or corrections. Logging and Cookies Unless explicitly stated otherwise, all material is copyright © The University of Edinburgh |