This page describes the purpose and content of each lecture. This gives you a way to check that you have understood the expected concepts and it can also be used as an index to find out where in the material certain concepts are covered.
Cases and Recursion
Purpose:
- Present general course information
- Help students get started using GHCi and loading program files
- Teach basic Haskell programming
- Prepare for lab 1
Content:
- Getting started using GHCi and loading program files
- Basic function definitions
- Evaluation by substituting variables in expressions
- Guards, if-then-else
- Recursion
- Basic introduction to lists and strings
- Types:
- Functions with many arguments (curried functions)
Integer
, String
, [a]
Material:
- The slides, lists
- LYAH:
- Chapter 1
- Chapter 2, sections 1-4 (but you are encouraged to read the whole chapter)
- Chapter 3, section 1 (but you are encouraged to read the whole chapter)
- There may be a few unfamiliar things if you haven’t read all of chapter 2, but you can just skip those bits
- Use Hoogle to look up any unfamiliar functions
- For example, try searching for
+
, max
or Num
- You can also search by type:
a -> String +base
(I added +base
to remove hits from irrelevant packages)
- Optional: Video recordings of a similar lecture by David Sands (for MSc students): part 1, part 2
Data Types
Purpose:
- Modelling problems using data types with components
- Using recursive data types to model things of varying size
- Using recursive functions to manipulate recursive data types
- Introduction to testing with properties
- Prepare for lab 2
Content:
- Defining non-recursive and recursive data types
- Data constructors
- Record syntax
- The
Eq
and Show
classes
- Automatic deriving of type class instances
- Wildcards
_
in function definitions
- QuickCheck:
- Properties
- Implication
==>
- The
Arbitrary
class
- etc.
Material:
Recursive Data Types and Lists
Purpose:
- Explain data types from the previous lecture in detail
- Introduce Haskell’s built-in lists
- Explain polymorphic types and types with class constraints
- Prepare for lab 3
Content:
- Data type definitions
- Data constructors
- Defining functions by pattern matching
- Programming with lists
Material:
More Lists
Purpose:
- Demonstrate programming with lists
- Explain list comprehension
- Demonstrate using QuickCheck
- Prepare for lab 3
Material:
IO Instructions
Purpose:
- Explain how pure functional programs can interact with their environment
- Basic input/output in Haskell
- Focus on how to use IO without explaining the underlying details
Content:
- Standard functions for input/output
- The
IO
type (“instructions”)
- Composing instructions
do
notation
- Conditional and recursive instructions
Material:
Test Data Generation
Purpose:
- Show how to generate test data for new data types
- Show how to generate test data tailored to specific problems
- Show an example of an “instruction type” different from
IO
Content:
- The
Gen
type for test data generators
- Making complicated generators from basic ones
- using combining functions
- using
do
notation
- The
Arbitrary
class
- Generate data types with invariants
- How to affect the distribution of test data
Material:
Higher-Order Functions
Purpose:
- Teach the general concept of higher-order functions
- Show how higher-order functions can be used to capture reusable programming patterns
Content:
- Higher-order functions: functions that take functions as arguments or return functions
- Types of higher-order functions
- Higher-order functions in Haskell’s libraries (
map
, filter
, fold
, etc.)
- λ-expressions
- Operator sections
- Function composition
(.)
- Partial applications
- “Curried” functions
- Solving problems using existing higher-order functions
- How list comprehensions are translated
Material:
Recursive Data Types
Purpose:
- Show how to use recursive data types to model tree-shaped data
- Show how to model and work with simple expression languages
- Prepare for lab 4
Content:
- Representing expressions
- Pretty printing (showing) expressions as strings
- Making a custom instance of the
Show
class
- Generating random expressions
- Evaluating and manipulating expressions
Material:
More Recursive Data Types
Purpose:
- Show how to parse (read) expressions from strings
- Prepare for lab 4
- Show another example of a recursive tree data type
Content:
- Parsing
- Case expressions
- Testing a parser
- Game for guessing animals using yes/no questions
Material:
Data Structures
Purpose:
- Show examples of functional data structures
- Show basic reasoning about efficiency of data structures
- Show how to move from an inefficient specification to an efficient implementation without introducing bugs
Content:
- Queue data structure
- Table data structure
- Using QuickCheck to verify efficient implementations
Material:
Haskell in the Browser
Purpose:
- Show how to write graphical user interfaces (GUIs) in Haskell
- Show the design philosophy of separating program logic from interaction
- Prepare for lab 4
Content:
- The Haste compiler
- Building web pages in Haskell
- Interactive web pages
- Graphics and animations
Material:
Laziness and Parallelism
Purpose:
- Explain lazy evaluation and its benefits
- Use the quiz to make sure that you have understood (will be published after the lecture)
- Raise awareness of the increasing use of parallel hardware and the need to run computations in parallel
- Show how pure functional programs are suitable for parallelization
- (Hopfully live demo on a multi-core machine)
Material: