Introduction to Functional Programming
Graham Hutton
School of Computer Science
University of Nottingham
Functional programming is a style of programming in which the primary
method of computation is the application of functions to arguments.
The aim of this course is to review some of the basics of functional
programming, using the modern functional language Haskell. The course
comprises ten mini-lectures, each with exercises, and concludes
with an extended programming example:
- Introduction
(what is functional programming,
why is it useful,
this course);
- The Hugs system
(what is hugs,
the standard prelude,
function application,
my first script);
- Types and classes I
(what is a type,
types in Haskell,
basic types,
list types,
tuple types,
function types);
- Types and classes II
(curried functions,
curry conventions,
polymorphic types,
overloaded types,
classes in Haskell);
- Defining functions
(conditional expressions,
guarded equations,
pattern matching,
list patterns,
lambda expressions,
why are lambda useful);
- List comprehensions
(set comprehensions,
list comprehensions,
dependant generators,
guards);
- Recursive functions
(recursive functions,
why is recursion useful,
recursion on lists,
quicksort);
- Higher-order functions
(why are they useful,
the map function,
the filter function,
the foldr function,
why is foldr useful);
- Interactive programs
(the problem,
the solution,
primitive actions,
sequencing actions,
other library actions,
example);
- Defining types
(data declarations,
recursive types,
arithmetic expressions)
- The countdown problem
(what is countdown,
rules,
evaluating expressions,
specifying the problem,
brute force implementation,
correctness theorem,
how fast is it,
can we do better,
applying program fusion,
how fast is it now,
can we do better,
exploiting properties,
how fast is it now,
further work).
This course was prepared for the
Summer School on
Advanced Functional Programming held in
Oxford during August 2002. The slides are available in
powerpoint
and PDF formats.