Half-title
Title
Copyright
Dedication
Contents
Preface
Chapter 1 Introduction
1.1 Functions
1.2 Functional programming
1.3 Features of Haskell
1.4 Historical background
1.5 A taste of Haskell
1.6 Chapter remarks
1.7 Exercises
Chapter 2 First steps
2.1 The Hugs system
2.2 The standard prelude
2.3 Function application
2.4 Haskell scripts
My first script
Naming requirements
The layout rule
Comments
2.5 Chapter remarks
2.6 Exercises
Chapter 3 Types and classes
3.1 Basic concepts
3.2 Basic types
Bool – logical values
Char – single characters
String – strings of characters
Int – fixed-precision integers
Integer – arbitrary-precision integers
Float – single-precision floating-point numbers
3.3 List types
3.4 Tuple types
3.5 Function types
3.6 Curried functions
3.7 Polymorphic types
3.8 Overloaded types
3.9 Basic classes
Eq – equality types
Ord – ordered types
Show – showable types
Read – readable types
Num – numeric types
Integral – integral types
Fractional – fractional types
3.10 Chapter remarks
3.11 Exercises
Chapter 4 Defining functions
4.1 New from old
4.2 Conditional expressions
4.3 Guarded equations
4.4 Pattern matching
Tuple patterns
List patterns
Integer patterns
4.5 Lambda expressions
4.6 Sections
4.7 Chapter remarks
4.8 Exercises
Chapter 5 List comprehensions
5.1 Generators
5.2 Guards
5.3 The zip function
5.4 String comprehensions
5.5 The Caesar cipher
Encoding and decoding
Frequency tables
Cracking the cipher
5.6 Chapter remarks
5.7 Exercises
Chapter 6 Recursive functions
6.1 Basic concepts
6.2 Recursion on lists
6.3 Multiple arguments
6.4 Multiple recursion
6.5 Mutual recursion
6.6 Advice on recursion
Example – product
Step 1: define the type
Step 2: enumerate the cases
Step 3: define the simple cases
Step 4: define the other cases
Step 5: generalise and simplify
Example – drop
Step 1: define the type
Step 2: enumerate the cases
Step 3: define the simple cases
Step 4: define the other cases
Step 5: generalise and simplify
Example – init
Step 1: define the type
Step 2: enumerate the cases
Step 3: define the simple cases
Step 4: define the other cases
Step 5: generalise and simplify
6.7 Chapter remarks
6.8 Exercises
Chapter 7 Higher-order functions
7.1 Basic concepts
7.2 Processing lists
7.3 The foldr function
7.4 The foldl function
7.5 The composition operator
7.6 String transmitter
Binary numbers
Base conversion
Transmission
7.7 Chapter remarks
7.8 Exercises
Chapter 8 Functional parsers
8.1 Parsers
8.2 The parser type
8.3 Basic parsers
8.4 Sequencing
8.5 Choice
8.6 Derived primitives
8.7 Handling spacing
8.8 Arithmetic expressions
8.9 Chapter remarks
8.10 Exercises
Chapter 9 Interactive programs
9.1 Interaction
9.2 The input/output type
9.3 Basic actions
9.4 Sequencing
9.5 Derived primitives
9.6 Calculator
9.7 Game of life
9.8 Chapter remarks
9.9 Exercises
Chapter 10 Declaring types and classes
10.1 Type declarations
10.2 Data declarations
10.3 Recursive types
10.4 Tautology checker
10.5 Abstract machine
10.6 Class and instance declarations
Derived instances
Monadic types
10.7 Chapter remarks
10.8 Exercises
Chapter 11 The countdown problem
11.1 Introduction
11.2 Formalising the problem
11.3 Brute force solution
11.4 Combining generation and evaluation
11.5 Exploiting algebraic properties
11.6 Chapter remarks
11.7 Exercises
Chapter 12 Lazy evaluation
12.1 Introduction
12.2 Evaluation strategies
Lambda expressions
12.3 Termination
12.4 Number of reductions
12.5 Infinite structures
12.6 Modular programming
12.7 Strict application
12.8 Chapter remarks
12.9 Exercises
Chapter 13 Reasoning about programs
13.1 Equational reasoning
13.2 Reasoning about Haskell
13.3 Simple examples
13.4 Induction on numbers
13.5 Induction on lists
13.6 Making append vanish
13.7 Compiler correctness
13.8 Chapter remarks
13.9 Exercises
Appendix A Standard prelude
A.1 Classes
A.2 Logical values
A.3 Characters and strings
A.4 Numbers
A.5 Tuples
A.6 Maybe
A.7 Lists
A.8 Functions
A.9 Input/output
Appendix B Symbol table
Bibliography
Index