Preface |
Introducing functional programming / 1: |
Computers and modelling / 1.1: |
What is a function? / 1.2: |
Pictures and functions / 1.3: |
Types / 1.4: |
The Haskell programming language / 1.5: |
Expressions and evaluation / 1.6: |
Definitions / 1.7: |
Function definitions / 1.8: |
Types and functional programming / 1.9: |
Calculation and evaluation / 1.10: |
The essence of Haskell programming / 1.11: |
Domain-specific languages / 1.12: |
Two models of Pictures / 1.13: |
Tests, properties and proofs / 1.14: |
Getting started with Haskell and GHCi / 2: |
A first Haskell program / 2.1: |
Using Haskell in practice / 2.2: |
Using GHCi / 2.3: |
The standard prelude and the Haskell libraries / 2.4: |
Modules / 2.5: |
A second example: pictures / 2.6: |
Errors and error messages / 2.7: |
Basic types and definitions / 3: |
The Booleans: Bool / 3.1: |
The integers: Integer and Int / 3.2: |
Overloading / 3.3: |
Guards / 3.4: |
Characters and strings / 3.5: |
Floating-point numbers: Float / 3.6: |
Syntax / 3.7: |
Designing and writing programs / 4: |
Where do I start? Designing a program in Haskell / 4.1: |
Solving a problem in steps: local definitions / 4.2: |
Defining types for ourselves: enumerated types / 4.3: |
Recursion / 4.4: |
Primitive recursion in practice / 4.5: |
Extended exercise: pictures / 4.6: |
General forms of recursion / 4.7: |
Program testing / 4.8: |
Data types, tuples and lists / 5: |
Introducing tuples and lists / 5.1: |
Tuple types / 5.2: |
Introducing algebraic types / 5.3: |
Our approach to lists / 5.4: |
Lists in Haskell / 5.5: |
List comprehensions / 5.6: |
A library database / 5.7: |
Programming with lists / 6: |
Generic functions: polymorphism / 6.1: |
Haskell list functions in the Prelude / 6.2: |
Finding your way around the Haskell libraries / 6.3: |
The Picture example: implementation / 6.4: |
Extended exercise: alternative implementations of pictures / 6.5: |
Extended exercise: positioned pictures / 6.6: |
Extended exercise: supermarket billing / 6.7: |
Extended exercise: cards and card games / 6.8: |
Defining functions over lists / 7: |
Pattern matching revisited / 7.1: |
Lists and list patterns / 7.2: |
Primitive recursion over lists / 7.3: |
Finding primitive recursive definitions / 7.4: |
General recursions over lists / 7.5: |
Example: text processing / 7.6: |
Playing the game: I/O in Haskell / 8: |
Rock - Paper - Scissors: strategies / 8.1: |
Why is I/O an issue? / 8.2: |
The basics of input/output / 8.3: |
The do notation / 8.4: |
Loops and recursion / 8.5: |
Rock - Paper - Scissors: playing the game / 8.6: |
Reasoning about programs / 9: |
Understanding definitions / 9.1: |
Testing and proof / 9.2: |
Definedness, termination and finiteness / 9.3: |
A little logic / 9.4: |
Induction / 9.5: |
Further examples of proofs by induction / 9.6: |
Generalizing the proof goal / 9.7: |
Generalization: patterns of computation / 10: |
Patterns of computation over lists / 10.1: |
Higher-order functions: functions as arguments / 10.2: |
Folding and primitive recursion / 10.3: |
Generalizing: splitting up lists / 10.4: |
Case studies revisited / 10.5: |
Higher-order functions / 11: |
Operators: function composition and application / 11.1: |
Expressions for functions: lambda abstractions / 11.2: |
Partial application / 11.3: |
Under the hood: curried functions / 11.4: |
Defining higher-order functions / 11.5: |
Verification and general functions / 11.6: |
Developing higher-order programs / 12: |
Revisiting the Picture example / 12.1: |
Functions as data: strategy combinators / 12.2: |
Functions as data: recognizing regular expressions / 12.3: |
Case studies: functions as data / 12.4: |
Example: creating an index / 12.5: |
Development in practice / 12.6: |
Understanding programs / 12.7: |
Overloading, type classes and type checking / 13: |
Why overloading? / 13.1: |
Introducing classes / 13.2: |
Signatures and instances / 13.3: |
A tour of the built-in Haskell classes / 13.4: |
Type checking and type inference: an overview / 13.5: |
Monomorphic type checking / 13.6: |
Polymorphic type checking / 13.7: |
Type checking and classes / 13.8: |
Algebraic types / 14: |
Algebraic type definitions revisited / 14.1: |
Recursive algebraic types / 14.2: |
Polymorphic algebraic types / 14.3: |
Modelling program errors / 14.4: |
Design with algebraic data types / 14.5: |
Algebraic types and type classes / 14.6: |
Reasoning about algebraic types / 14.7: |
Case study: Huffman codes / 15: |
Modules in Haskell / 15.1: |
Modular design / 15.2: |
Coding and decoding / 15.3: |
Implementation - I / 15.4: |
Building Huffman trees / 15.5: |
Design / 15.6: |
Implementation - II / 15.7: |
Abstract data types / 16: |
Type representations / 16.1: |
The Haskell abstract data type mechanism / 16.2: |
Queues / 16.3: |
Simulation / 16.4: |
Implementing the simulation / 16.6: |
Search trees / 16.7: |
Sets / 16.8: |
Relations and graphs / 16.9: |
Commentary / 16.10: |
Lazy programming / 17: |
Lazy evaluation / 17.1: |
Calculation rules and lazy evaluation / 17.2: |
List comprehensions revisited / 17.3: |
Data-directed programming / 17.4: |
Case study: parsing expressions / 17.5: |
Infinite lists / 17.6: |
Why infinite lists? / 17.7: |
Case study: simulation / 17.8: |
Proof revisited / 17.9: |
Programming with monads / 18: |
I/O programming / 18.1: |
Further I/O / 18.2: |
The calculator / 18.3: |
The do notation revisited / 18.4: |
Monads: languages for functional programming / 18.5: |
Example: monadic computation over trees / 18.6: |
Programming languages everywhere / 19: |
Why DSLs in Haskell? / 19.2: |
Shallow and deep embeddings / 19.3: |
A DSL for regular expressions / 19.4: |
Monadic DSLs / 19.5: |
DSLs for computation: generating data in QuickCheck / 19.6: |
Taking it further / 19.7: |
Time and space behaviour / 20: |
Complexity of functions / 20.1: |
The complexity of calculations / 20.2: |
Implementations of sets / 20.3: |
Space behaviour / 20.4: |
Folding revisited / 20.5: |
Avoiding recomputation: memoization / 20.6: |
Conclusion / 21: |
Appendices |
Functional, imperative and OO programming / A: |
Glossary / B: |
Haskell operators / C: |
Haskell practicalities / D: |
GHCi errors / E: |
Project ideas / F: |
Bibliography |
Preface |
Introducing functional programming / 1: |
Computers and modelling / 1.1: |
What is a function? / 1.2: |
Pictures and functions / 1.3: |
Types / 1.4: |