1.Introduction
- 1.1Functional JavaScript
- 1.2Types and Type Inference
- 1.3Polyglot Web Programming
- 1.4Prerequisites
- 1.5About You
- 1.6How to Read This Book
- 1.7Getting Help
- 1.8About the Author
- 1.9Acknowledgements
2.Getting Started
- 2.1Chapter Goals
- 2.2Introduction
- 2.3Installing PureScript
- 2.4Installing Tools
- 2.5Hello, PureScript!
- 2.6Compiling for the Browser
- 2.7Removing Unused Code
- 2.8Compiling CommonJS Modules
- 2.9Tracking Dependencies with Bower
- 2.10Computing Diagonals
- 2.11Testing Code Using the Interactive Mode
- Exercises
- 2.12Conclusion
3.Functions and Records
- 3.1Chapter Goals
- 3.2Project Setup
- 3.3Simple Types
- 3.4Quantified Types
- 3.5Notes On Indentation
- 3.6Defining Our Types
- 3.7Type Constructors and Kinds
- 3.8Displaying Address Book Entries
- 3.9Test Early, Test Often
- 3.10Creating Address Books
- 3.11Curried Functions
- 3.12Querying the Address Book
- 3.13Infix Function Application
- 3.14Function Composition
- 3.15Tests, Tests, Tests …
- Exercises
- 3.16Conclusion
4.Recursion, Maps And Folds
- 4.1Chapter Goals
- 4.2Project Setup
- 4.3Introduction
- 4.4Recursion on Arrays
- Exercises
- 4.5Maps
- 4.6Infix Operators
- 4.7Filtering Arrays
- Exercises
- 4.8Flattening Arrays
- 4.9Array Comprehensions
- 4.10Do Notation
- 4.11Guards
- Exercises
- 4.12Folds
- 4.13Tail Recursion
- 4.14Accumulators
- 4.15Prefer Folds to Explicit Recursion
- Exercises
- 4.16A Virtual Filesystem
- 4.17Listing All Files
- Exercises
- 4.18Conclusion
5.Pattern Matching
- 5.1Chapter Goals
- 5.2Project Setup
- 5.3Simple Pattern Matching
- 5.4Simple Patterns
- 5.5Guards
- Exercises
- 5.6Array Patterns
- 5.7Record Patterns and Row Polymorphism
- 5.8Nested Patterns
- 5.9Named Patterns
- Exercises
- 5.10Case Expressions
- 5.11Pattern Match Failures and Partial Functions
- 5.12Algebraic Data Types
- 5.13Using ADTs
- 5.14Record Puns
- Exercises
- 5.15Newtypes
- 5.16A Library for Vector Graphics
- 5.17Computing Bounding Rectangles
- Exercises
- 5.18Conclusion
6.Type Classes
- 6.1Chapter Goals
- 6.2Project Setup
- 6.3Show Me!
- Exercises
- 6.4Common Type Classes
- Exercises
- 6.5Type Annotations
- 6.6Overlapping Instances
- 6.7Instance Dependencies
- Exercises
- 6.8Multi Parameter Type Classes
- 6.9Functional Dependencies
- 6.10Nullary Type Classes
- 6.11Superclasses
- Exercises
- 6.12A Type Class for Hashes
- Exercises
- 6.13Conclusion
7.Applicative Validation
- 7.1Chapter Goals
- 7.2Project Setup
- 7.3Generalizing Function Application
- 7.4Lifting Arbitrary Functions
- 7.5The Applicative Type Class
- 7.6Intuition for Applicative
- 7.7More Effects
- 7.8Combining Effects
- Exercises
- 7.9Applicative Validation
- 7.10Regular Expression Validators
- Exercises
- 7.11Traversable Functors
- Exercises
- 7.12Applicative Functors for Parallelism
- 7.13Conclusion
8.The Eff Monad
- 8.1Chapter Goals
- 8.2Project Setup
- 8.3Monads and Do Notation
- 8.4The Monad Type Class
- 8.5Monad Laws
- 8.6Folding With Monads
- 8.7Monads and Applicatives
- Exercises
- 8.8Native Effects
- 8.9Side-Effects and Purity
- 8.10The Eff Monad
- 8.11Extensible Effects
- 8.12Interleaving Effects
- 8.13The Kind of Eff
- 8.14Records And Rows
- 8.15Fine-Grained Effects
- 8.16Handlers and Actions
- 8.17Mutable State
- Exercises
- 8.18DOM Effects
- 8.19An Address Book User Interface
- Exercises
- 8.20Conclusion
9.Canvas Graphics
- 9.1Chapter Goals
- 9.2Project Setup
- 9.3Simple Shapes
- 9.4Putting Row Polymorphism to Work
- Exercises
- 9.5Drawing Random Circles
- 9.6Transformations
- 9.7Preserving the Context
- 9.8Global Mutable State
- Examples
- 9.9L-Systems
- Exercises
- 9.10Conclusion
10.The Foreign Function Interface
- 10.1Chapter Goals
- 10.2Project Setup
- 10.3A Disclaimer
- 10.4Calling PureScript from JavaScript
- 10.5Understanding Name Generation
- 10.6Runtime Data Representation
- 10.7Representing ADTs
- 10.8Representing Quantified Types
- 10.9Representing Constrained Types
- Exercises
- 10.10Using JavaScript Code From PureScript
- 10.11Wrapping JavaScript Values
- 10.12Defining Foreign Types
- 10.13Functions of Multiple Arguments
- 10.14Representing Side Effects
- 10.15Defining New Effects
- Exercises
- 10.16Working With Untyped Data
- 10.17Handling Null and Undefined Values
- 10.18Generic JSON Serialization
- Exercises
- 10.19Conclusion
11.Monadic Adventures
- 11.1Chapter Goals
- 11.2Project Setup
- 11.3How To Play The Game
- 11.4The State Monad
- Exercises
- 11.5The Reader Monad
- Exercises
- 11.6The Writer Monad
- Exercises
- 11.7Monad Transformers
- 11.8The ExceptT Monad Transformer
- 11.9Monad Transformer Stacks
- Exercises
- 11.10Type Classes to the Rescue!
- 11.11Alternatives
- 11.12Monad Comprehensions
- 11.13Backtracking
- Exercises
- 11.14The RWS Monad
- 11.15Implementing Game Logic
- 11.16Running the Computation
- Exercises
- 11.17Handling Command Line Options
- Exercises
- 11.18Conclusion
12.Callback Hell
- 12.1Chapter Goals
- 12.2Project Setup
- 12.3The Problem
- 12.4The Continuation Monad
- Exercises
- 12.5Putting ExceptT To Work
- Exercises
- 12.6A HTTP Client
- Exercises
- 12.7Parallel Computations
- Exercises
- 12.8Conclusion
13.Generative Testing
- 13.1Chapter Goals
- 13.2Project Setup
- 13.3Writing Properties
- 13.4Improving Error Messages
- Exercises
- 13.5Testing Polymorphic Code
- Exercises
- 13.6Generating Arbitrary Data
- Exercises
- 13.7Testing Higher-Order Functions
- 13.8Writing Coarbitrary Instances
- 13.9Testing Without Side-Effects
- Exercises
- 13.10Conclusion
14.Domain-Specific Languages
- 14.1Chapter Goals
- 14.2Project Setup
- 14.3A HTML Data Type
- 14.4Smart Constructors
- Exercises
- 14.5Phantom Types
- Exercises
- 14.6The Free Monad
- 14.7Interpreting the Monad
- Exercises
- 14.8Extending the Language
- Exercises
- 14.9Conclusion
