PureScript by Example

PureScript by Example

Phil Freeman
Buy on Leanpub

Table of Contents

PureScript by Example

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

PureScript by Example

course_overview

Learn functional programming for the web using PureScript, by solving practical problems.

count_chapters
begin_reading
download
p_implied_book_part_name

PureScript by Example14 chapters

Begin ›
  1. 1. Introduction

  2. 2. Getting Started

  3. 3. Functions and Records

  4. 4. Recursion, Maps And Folds

  5. 5. Pattern Matching

  6. 6. Type Classes

  7. 7. Applicative Validation

  8. 8. The Eff Monad

  9. 9. Canvas Graphics

  10. 10. The Foreign Function Interface

  11. 11. Monadic Adventures

  12. 12. Callback Hell

  13. 13. Generative Testing

  14. 14. Domain-Specific Languages