## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

## Book Description

Functional programming is a style of programming that emphasizes the use of functions (in contrast to object-oriented programming, which emphasizes the use of objects). It has become popular in recent years because of its simplicity, conciseness, and clarity. This book, first published in 2000, teaches functional programming as a way of thinking and problem solving, using Haskell, the most popular purely functional language. Rather than using the conventional (boring) mathematical examples commonly found in other programming language textbooks, the author uses examples drawn from multimedia applications, including graphics, animation, and computer music, thus rewarding the reader with working programs for inherently more interesting applications. Aimed at both beginning and advanced programmers, this tutorial begins with a gentle introduction to functional programming and moves rapidly on to more advanced topics. Details about progamming in Haskell are presented in boxes throughout the text so they can be easily found and referred to.

1. Cover
2. Title
4. Contents
5. Preface
6. 1 Problem Solving, Programming, and Calculation
1. 1.1 Computation by Calculation in Haskell
2. 1.2 Expressions, Values, and Types
3. 1.3 Function Types and Type Signatures
4. 1.4 Abstraction, Abstraction, Abstraction
5. 1.5 Code Reuse and Modularity
6. 1.6 Beware of Programming with Numbers
7. 2 A Module of Shapes: Part I
8. 3 Simple Graphics
9. 4 Shapes II: Drawing Shapes
10. 5 Polymorphic and Higher-Order Functions
1. 5.1 Polymorphic Types
2. 5.2 Abstraction Over Recursive Definitions
3. 5.3 Append
4. 5.4 Fold
5. 5.5 A Final Example: Reverse
6. 5.6 Errors
11. 6 Shapes III: Perimeters of Shapes
12. 7 Trees
13. 8 A Module of Regions
1. 8.1 The Region Data Type
2. 8.2 The Meaning of Shapes and Regions
3. 8.3 Algebraic Properties of Regions
4. 8.4 In Retrospect
14. 9 More About Higher-Order Functions
15. 10 Drawing Regions
1. 10.1 The Picture Data Type
2. 10.2 Drawing Pictures
3. 10.3 Drawing Regions
4. 10.4 User Interaction
5. 10.5 Putting it all Together
16. 11 Proof by Induction
1. 11.1 Induction and Recursion
2. 11.2 Examples of List Induction
3. 11.3 Useful Properties on Lists
4. 11.4 Induction on Other Data Types
17. 12 Qualified Types
18. 13 A Module of Simple Animations
1. 13.1 What is an Animation?
2. 13.2 Representing an Animation
3. 13.3 An Animator
4. 13.4 Fun With Type Classes
5. 13.5 Lifting to the Limit
6. 13.6 Time Transformation
7. 13.7 A Final Example: A Kaleidoscope Program
19. 14 Programming With Streams
20. 15 A Module of Reactive Animations
1. 15.1 FAL by Example
2. 15.2 Implementing FAL
3. 15.3 The Implementation
4. 15.4 Extensions
5. 15.5 Paddleball in Twenty Lines
21. 16 Communicating With the Outside World
1. 16.1 Files, Channels, and Handles
2. 16.2 Exception Handling
3. 16.3 First-Class Channels and Concurrency
22. 17 Rendering Reactive Animations
23. 18 Higher-Order Types
1. 18.1 The Functor Class
5. 18.5 Type Class Type Errors
24. 19 An Imperative Robot Language
1. 19.1 IRL by Example
2. 19.2 Robot is a State Monad
3. 19.3 The Implementation of IRL Commands
4. 19.4 All the World is a Grid
5. 19.5 Robot Graphics
6. 19.6 Putting it all Together
25. 20 Functional Music Composition
1. 20.1 The Music Data Type
2. 20.2 Higher-Level Constructions
3. 20.3 A Couple of Final Examples
26. 21 Interpreting Functional Music
27. 22 From Performance to MIDI
28. 23 A Tour of the PreludeList Module
29. 24 A Tour of Haskell’s Standard Type Classes
30. A Built-in Types Are Not Special
31. B Pattern-Matching Details
32. Bibliography
33. Index