| Contents at a Glance | 3 |
|---|
| Contents | 397 |
|---|
| About the Author | 407 |
|---|
| About the Technical Reviewer | 408 |
|---|
| Acknowledgments | 409 |
|---|
| Introduction | 5 |
|---|
| Part 1: First Steps | 6 |
|---|
| Chapter 1: Going Functional | 7 |
| Why Haskell? | 7 |
| Why Pure Functional Programming? | 8 |
| Why Strong Static Typing? | 9 |
| The Haskell Ecosystem | 10 |
| The History of Haskell | 10 |
| Your Working Environment | 10 |
| Installing on Windows | 11 |
| Installing on Mac OS X | 11 |
| Installing on Linux | 12 |
| Installing on Linux from Source | 12 |
| Checking That the Installation Is Successful | 13 |
| Installing EclipseFP | 13 |
| Taking Your First Steps with GHCi | 15 |
| The Time Machine Store | 16 |
| Summary | 17 |
| Chapter 2: Declaring the Data Model | 18 |
| Working with Characters, Numbers, and Lists | 18 |
| Characters | 18 |
| Numbers | 20 |
| Strings | 21 |
| Lists | 21 |
| List Operations | 22 |
| Creating a New Project | 25 |
| Creating a Project from the Command Line | 25 |
| Creating a Project from EclipseFP | 25 |
| Understanding Modules | 28 |
| Defining Simple Functions | 29 |
| Creating a Simple Function | 29 |
| Specifying the Function s Type | 30 |
| Developing a Robust Example | 30 |
| Returning More Than One Value | 32 |
| Working with Data Types | 33 |
| Pattern Matching | 36 |
| Simple Patterns | 36 |
| Lists and Tuples | 40 |
| Guards | 41 |
| View Patterns | 43 |
| Records | 44 |
| Creation and Use | 44 |
| The Default Values Idiom | 46 |
| Summary | 48 |
| Chapter 3: Reusing Code Through Lists | 49 |
| Parametric Polymorphism | 49 |
| Functions As Parameters | 52 |
| Higher-Order Functions | 52 |
| Anonymous Functions | 54 |
| Partial Application of a Function | 56 |
| More on Modules | 59 |
| Module Imports | 59 |
| Smart Constructors and Views | 61 |
| Diving into Lists | 63 |
| Folds | 63 |
| Lists and Predicates | 66 |
| Lists Containing Tuples | 71 |
| List Comprehensions | 72 |
| Haskell Origami | 75 |
| Summary | 78 |
| Chapter 4: Using Containers and Type Classes | 79 |
| Using Packages | 79 |
| Managing Packages with Cabal and EclipseFP | 79 |
| Sandboxed Environments | 84 |
| Containers: Maps, Sets, Trees, Graphs | 86 |
| Maps | 86 |
| Sets | 89 |
| Trees | 91 |
| Graphs | 92 |
| Obtaining Help | 94 |
| Ad Hoc Polymorphism: Type Classes | 96 |
| Declaring Classes and Instances | 96 |
| Built-in Type Classes | 99 |
| Binary Tress for the Minimum Price | 103 |
| Step 1: Simple Binary Trees | 103 |
| Step 2: Polymorphic Binary Trees | 104 |
| Step 3: Binary Trees with Monoidal Cache | 106 |
| Container-Related Type Classes | 108 |
| Functors | 108 |
| Foldables | 109 |
| Summary | 111 |
| Chapter 5: Laziness and Infinite Structures | 112 |
| An Infinite Number of Time Machines | 1
|