You are previewing Programming in Haskell.
O'Reilly logo
Programming in Haskell

Book Description

Haskell is one of the leading languages for teaching functional programming, enabling students to write simpler and cleaner code, and to learn how to structure and reason about programs. This introduction is ideal for beginners: it requires no previous programming experience and all concepts are explained from first principles via carefully chosen examples. Each chapter includes exercises that range from the straightforward to extended projects, plus suggestions for further reading on more advanced topics. The author is a leading Haskell researcher and instructor, well-known for his teaching skills. The presentation is clear and simple, and benefits from having been refined and class-tested over several years. The result is a text that can be used with courses, or for self-learning. Features include freely accessible Powerpoint slides for each chapter, solutions to exercises and examination questions (with solutions) available to instructors, and a downloadable code that's fully compliant with the latest Haskell release.

Table of Contents

  1. Cover
  2. Half Title
  3. Title Page
  4. Copyright
  5. Dedication
  6. Contents
  7. Preface
  8. Chapter 1: Introduction
    1. 1.1 Functions
    2. 1.2 Functional programming
    3. 1.3 Features of Haskell
    4. 1.4 Historical background
    5. 1.5 A taste of Haskell
    6. 1.6 Chapter remarks
    7. 1.7 Exercises
  9. Chapter 2: First steps
    1. 2.1 The Hugs system
    2. 2.2 The standard prelude
    3. 2.3 Function application
    4. 2.4 Haskell scripts
    5. 2.5 Chapter remarks
    6. 2.6 Exercises
  10. Chapter 3: Types and classes
    1. 3.1 Basic concepts
    2. 3.2 Basic types
    3. 3.3 List types
    4. 3.4 Tuple types
    5. 3.5 Function types
    6. 3.6 Curried functions
    7. 3.7 Polymorphic types
    8. 3.8 Overloaded types
    9. 3.9 Basic classes
    10. 3.10 Chapter remarks
    11. 3.11 Exercises
  11. Chapter 4: Defining functions
    1. 4.1 New from old
    2. 4.2 Conditional expressions
    3. 4.3 Guarded equations
    4. 4.4 Pattern matching
    5. 4.5 Lambda expressions
    6. 4.6 Sections
    7. 4.7 Chapter remarks
    8. 4.8 Exercises
  12. Chapter 5: List comprehensions
    1. 5.1 Generators
    2. 5.2 Guards
    3. 5.3 The zip function
    4. 5.4 String comprehensions
    5. 5.5 The Caesar cipher
    6. 5.6 Chapter remarks
    7. 5.7 Exercises
  13. Chapter 6: Recursive functions
    1. 6.1 Basic concepts
    2. 6.2 Recursion on lists
    3. 6.3 Multiple arguments
    4. 6.4 Multiple recursion
    5. 6.5 Mutual recursion
    6. 6.6 Advice on recursion
    7. 6.7 Chapter remarks
    8. 6.8 Exercises
  14. Chapter 7: Higher-order functions
    1. 7.1 Basic concepts
    2. 7.2 Processing lists
    3. 7.3 The foldr function
    4. 7.4 The foldl function
    5. 7.5 The composition operator
    6. 7.6 String transmitter
    7. 7.7 Chapter remarks
    8. 7.8 Exercises
  15. Chapter 8: Functional parsers
    1. 8.1 Parsers
    2. 8.2 The parser type
    3. 8.3 Basic parsers
    4. 8.4 Sequencing
    5. 8.5 Choice
    6. 8.6 Derived primitives
    7. 8.7 Handling spacing
    8. 8.8 Arithmetic expressions
    9. 8.9 Chapter remarks
    10. 8.10 Exercises
  16. Chapter 9: Interactive programs
    1. 9.1 Interaction
    2. 9.2 The input/output type
    3. 9.3 Basic actions
    4. 9.4 Sequencing
    5. 9.5 Derived primitives
    6. 9.6 Calculator
    7. 9.7 Game of life
    8. 9.8 Chapter remarks
    9. 9.9 Exercises
  17. Chapter 10: Declaring types and classes
    1. 10.1 Type declarations
    2. 10.2 Data declarations
    3. 10.3 Recursive types
    4. 10.4 Tautology checker
    5. 10.5 Abstract machine
    6. 10.6 Class and instance declarations
    7. 10.7 Chapter remarks
    8. 10.8 Exercises
  18. Chapter 11: The countdown problem
    1. 11.1 Introduction
    2. 11.2 Formalising the problem
    3. 11.3 Brute force solution
    4. 11.4 Combining generation and evaluation
    5. 11.5 Exploiting algebraic properties
    6. 11.6 Chapter remarks
    7. 11.7 Exercises
  19. Chapter 12: Lazy evaluation
    1. 12.1 Introduction
    2. 12.2 Evaluation strategies
    3. 12.3 Termination
    4. 12.4 Number of reductions
    5. 12.5 Infinite structures
    6. 12.6 Modular programming
    7. 12.7 Strict application
    8. 12.8 Chapter remarks
    9. 12.9 Exercises
  20. Chapter 13: Reasoning about programs
    1. 13.1 Equational reasoning
    2. 13.2 Reasoning about Haskell
    3. 13.3 Simple examples
    4. 13.4 Induction on numbers
    5. 13.5 Induction on lists
    6. 13.6 Making append vanish
    7. 13.7 Compiler correctness
    8. 13.8 Chapter remarks
    9. 13.9 Exercises
  21. Appendix A: Standard prelude
    1. A.1 Classes
    2. A.2 Logical values
    3. A.3 Characters and strings
    4. A.4 Numbers
    5. A.5 Tuples
    6. A.6 Maybe
    7. A.7 Lists
    8. A.8 Functions
    9. A.9 Input/output
  22. Appendix B: Symbol table
  23. Bibliography
  24. Index