liveBook · Manning

What you will learn in Learn Haskell by Example

by Philipp Hagenlocher

Chapter by chapter

Chapter 1: Introduction

1.1 What is Haskell? · 1.1.1 Abstraction and theory · 1.1.2 A safe place · 1.2 The pure functional way · 1.2.1 A declarative recipe · 1.2.2 From cake to program · 1.2.3 It’s all for simplicity · 1.3 Usage of abstraction · 1.3.1 The good parts · 1.3.2 The bad parts · 1.4 The things we learn · 1.5 Summary

What you learn in chapter 1 →

Chapter 2: Ancient secret keeping on modern machines

2.1 A primer on Haskell · 2.1.1 Caesar’s cipher · 2.1.2 A new project · 2.1.3 The first module · 2.2 Typical types and fantastic functions · 2.2.1 Types on the atomic level · 2.2.2 Lists and tuples · 2.2.3 Function types · 2.2.4 Adding types to math · 2.3 A little help with the alphabet · 2.3.1 Synonymous types for readability · 2.3.2 The kinds of letters · 2.3.3 Logical combinations · 2.4 Rotating the wheel · 2.4.1 Finding an element’s index · 2.4.2 Finding the element at an index · 2.4.3 Guarding control flow · 2.5 Transforming a string · 2.5.1 A higher-order mapping · 2.5.2 Parameterizing types · 2.5.3 A finished cipher · 2.6 Summary

What you learn in chapter 2 →

Chapter 3: Every line counts

3.1 Talking to the outside · 3.1.1 Simple actions for input and output · 3.1.2 Simulating a loop · 3.1.3 Breaking out of a recursive action · 3.2 Pure functions inside of actions · 3.2.1 Reading and modifying user input · 3.2.2 Data flow between pure and impure code · 3.3 Reading from the environment · 3.3.1 Parsing command line arguments · 3.3.2 Encoding errors with Maybe · 3.4 Example: Reading and printing a command line argument · 3.4.1 The let keyword · 3.4.2 Running the program with stack · 3.5 Summary

What you learn in chapter 3 →

Chapter 4: Line numbering tool

4.1 Reading files and transforming their content · 4.1.1 Writing a pure library · 4.1.2 Hiding auxiliary arguments · 4.2 Parametrized behavior in higher-order functions · 4.2.1 Partial function application · 4.3 Algebraic data structures as an encoding of possibilities · 4.3.1 Sum types or tagged unions · 4.3.2 Don’t repeat yourself · 4.3.3 The zip function · 4.3.4 Working with missing values · 4.3.5 Printing a list of values with mapM · 4.4 From library to executable · 4.4.1 Encoding and parsing command line options · 4.4.2 An overview of the project · 4.5 Summary

What you learn in chapter 4 →

Chapter 5: Words and graphs

5.1 Building a graph · 5.1.1 Polymorphic types · 5.1.2 Introducing a new module · 5.1.3 The Eq type class and type constraints · 5.1.4 The flip function · 5.2 Encapsulating implementations · 5.2.1 Adding and removing entries · 5.2.2 Using export lists to hide constructors · 5.2.3 The Show type class · 5.3 Using and reusing code · 5.3.1 Qualified imports · 5.3.2 Building maps for permutations · 5.3.3 Creating a permutation map from a dictionary · 5.4 Parameterizing transformations · 5.4.1 List comprehensions · 5.5 Summary

What you learn in chapter 5 →

Chapter 6: Solving the ladder game

6.1 Constructing a breadth-first search · 6.1.1 Overview of the algorithm · 6.1.2 Keeping track of search state · 6.1.3 Finding the solution by backtracking · 6.2 Type variable scoping · 6.2.1 Universal quantification · 6.2.2 Language extensions · 6.2.3 Using lexically scoped type variables · 6.3 Improving performance with hashmaps · 6.3.1 Analyzing performance with profiling · 6.3.2 Adding project dependencies · 6.3.3 Lazy evaluation · 6.4 Summary

What you learn in chapter 6 →

Chapter 7: Working with CSV files

7.1 Modeling CSV data · 7.1.1 Record syntax · 7.1.2 Encoding errors with Either · 7.2 Smart constructors · 7.2.1 Ensuring a property at the time of construction · 7.2.2 Providing an unsafe alternative · 7.2.3 The dollar sign operator · 7.3 Using type classes · 7.3.1 Semigroup and Monoid · 7.3.2 The IsString type class · 7.4 Creating a new type class · 7.4.1 A type class for slicing data structures · 7.4.2 Re-exporting modules · 7.5 Summary

What you learn in chapter 7 →

Chapter 8: A tool for CSV

8.1 Parsing data · 8.1.1 Parsing numeric values · 8.2 Folding data structures · 8.2.1 The concept of folding · 8.2.2 A structure for parsing · 8.2.3 The Functor type class · 8.2.4 Using folding for parsing · 8.3 Printing a CSV · 8.3.1 Operations on CSVs · 8.4 A simple command-line parser · 8.4.1 Supporting flags and complicated arguments · 8.5 Summary

What you learn in chapter 8 →

Chapter 9: Quick checks and random tests

9.1 How to test · 9.1.1 Property testing · 9.1.2 Generating random values · 9.1.3 Random and Uniform · 9.1.4 Using a global random value generator · 9.1.5 A basic property test · 9.1.6 Defining postconditions for random values · 9.2 Randomized testing · 9.2.1 The benefit of referential transparency · 9.3 The QuickCheck testing framework · 9.3.1 Using Property in QuickCheck · 9.4 Generating random values for testing · 9.4.1 The random generator Genrandom value function · 9.4.2 Example: AssocMap · 9.4.3 Shrinking test cases · 9.5 Practical usage of property testing · 9.5.1 Verbosity and coverage reports · 9.5.2 Modifying a test’s parameters · 9.5.3 Constructing test suites · 9.5.4 The effectiveness of testing · 9.6 Summary

What you learn in chapter 9 →

Chapter 10: Digital music box

10.1 Modeling sound with numbers · 10.1.1 The zoo of numeric type classes · 10.1.2 Creating periodic functions · 10.2 Using infinite lists · 10.2.1 Attack, decay, sustain, and release · 10.2.2 Building and working with infinite lists · 10.3 Controlling synthesis · 10.3.1 Partial field selectors · 10.3.2 A function as a type · 10.4 Note models · 10.4.1 A type class for pitches · 10.4.2 The Ratio type · 10.4.3 Different kinds of exponentiation · 10.5 Summary

What you learn in chapter 10 →

Chapter 11: Programming musical compositions

11.1 Polymorphic data structures with multiple types · 11.1.1 Existential quantification · 11.1.2 Using existentially quantified types · 11.2 Interpreting structures · 11.2.1 Mixing signals · 11.2.2 Groups of polyphony · 11.3 Implementing a domain-specific language · 11.3.1 Simplifying syntax · 11.3.2 Custom operators for list-like data structures · 11.3.3 Fixity declarations · 11.4 Summary

What you learn in chapter 11 →

Chapter 12: Parsing pixel data

12.1 Writing a parser · 12.1.1 Portable images from the past · 12.1.2 How to parse a file · 12.1.3 Composing effects · 12.1.4 Choosing alternatively · 12.1.5 Introducing monads · 12.1.6 A discussion on monads · 12.1.7 How to fail · 12.2 Parsing on a bigger scale · 12.2.1 An introduction to Attoparsec · 12.2.2 Parsing images · 12.2.3 Choosing between formats · 12.2.4 Putting parsers together · 12.3 Summary

What you learn in chapter 12 →

Chapter 13: Parallel image processing

13.1 Providing type information to the caller · 13.1.1 Problems with return-type polymorphism · 13.1.2 Generalized algebraic data types · 13.1.3 The Vector type · 13.1.4 Dynamic types with existential quantification · 13.2 Validation of parsed data · 13.3 A generic algorithm for image conversion · 13.3.1 Image algorithm for conversion matrices · 13.3.2 Exporting images as PNG · 13.4 Using parallelism to transform data · 13.4.1 Measuring time · 13.4.2 How parallelism works · 13.4.3 All about sparks image process HECs (Haskell execution contexts) · 13.5 Summary

What you learn in chapter 13 →

Chapter 14: Files and exceptions

14.1 Opening and reading files · 14.1.1 System.IO and Handle · 14.1.2 Buffering and Seeking · 14.2 Reading bytes from a file · 14.2.1 Resource acquisition and bracket · 14.3 Working with the filesystem and exceptions · 14.3.1 System.Directory and System.FilePath · 14.3.2 Listing files and directories · 14.3.3 The basics of exceptions · 14.4 Throwing and catching exceptions · 14.4.1 Handling an error · 14.5 Summary

What you learn in chapter 14 →

Chapter 15: Transformers for synchronizing

15.1 Monad transformers · 15.1.1 Reading an environment with ReaderT · 15.1.2 StateT and WriterT · 15.1.3 Stacking multiple transformers with RWST · 15.2 Implementing an application · 15.3 Providing a CLI · 15.3.1 Parsing arguments with optparse-applicative · 15.3.2 Enumerating custom types · 15.3.3 The Enum class · 15.3.4 A CLI for App · 15.4 Summary

What you learn in chapter 15 →

Chapter 16: JSON and SQL

16.1 Encoding values as JSON · 16.1.1 Aeson and JSON parsing · 16.1.2 Serializing to JSON · 16.2 Deriving type classes with Generic · 16.3 Using a SQLite database · 16.3.1 The basics of sqlite-simple · 16.3.2 ToRow and FromRow · 16.3.3 Defining actions for database access · 16.4 Summary

What you learn in chapter 16 →

Chapter 17: APIs using Servant

17.1 Defining a typesafe API · 17.1.1 Typed APIs with Servant · 17.1.2 Phantom types · 17.1.3 Implementing the API · 17.2 Running the application · 17.2.1 The WAI application · 17.2.2 Application middleware · 17.2.3 Producing HTML from data · 17.3 Deriving a client · 17.3.1 Using servant-client · 17.3.2 Defining commands for the CLI · 17.3.3 Implementing the client · 17.4 Summary

What you learn in chapter 17 →

Concepts explained in this book

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.