PureScript by Example
PureScript by Example
Functional Programming for the Web
About the Book
This book will show you how to get started with the PureScript programming language, from the basics (setting up a development environment) to the advanced.
Each chapter will be motivated by a particular problem, and in the course of solving that problem, new functional programming tools and techniques will be introduced. Here are some examples of problems that will be solved in this book:
- Transforming data structures with maps and folds
- Form field validation using applicative functors
- Testing code with QuickCheck
- Using the canvas
- Domain specific language implementation
- Working with the DOM
- Dealing with callback hell
- 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 Records 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.5 Understanding Name Generation
- 10.6 Runtime Data Representation
- 10.7 Representing ADTs
- 10.8 Representing Quantified Types
- 10.9 Representing Constrained Types
- 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
A nationwide network of volunteer-led after school coding clubs for children aged 9-11.
The Leanpub 45-day 100% Happiness Guarantee
Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
C++ Best PracticesJason Turner
Level up your C++, get the tools working for you, eliminate common problems, and move on to more exciting things!
Continuous Delivery PipelinesDave Farley
This practical handbook provides a step-by-step guide for you to get the best continuous delivery pipeline for your software.
OpenIntro StatisticsDavid Diez, Christopher Barr, Mine Cetinkaya-Rundel, and OpenIntro
A complete foundation for Statistics, also serving as a foundation for Data Science.
Leanpub revenue supports OpenIntro (US-based nonprofit) so we can provide free desk copies to teachers interested in using OpenIntro Statistics in the classroom and expand the project to support free textbooks in other subjects.
More resources: openintro.org.
C++20 is the next big C++ standard after C++11. As C++11 did it, C++20 changes the way we program modern C++. This change is, in particular, due to the big four of C++20: ranges, coroutines, concepts, and modules.
The book is almost daily updated. These incremental updates ease my interaction with the proofreaders.
Atomic KotlinBruce Eckel and Svetlana Isakova
For both beginning and experienced programmers! From the author of the multi-award-winning Thinking in C++ and Thinking in Java together with a member of the Kotlin language team comes a book that breaks the concepts into small, easy-to-digest "atoms," along with exercises supported by hints and solutions directly inside IntelliJ IDEA!
Introductory Statistics with Randomization and SimulationMine Cetinkaya-Rundel, Christopher Barr, OpenIntro, and David Diez
A complete foundation for Statistics, also serving as a foundation for Data Science, that introduces inference using randomization and simulation while covering traditional methods.
Leanpub revenue supports OpenIntro, so we can provide free desk copies to teachers interested in using our books in the classroom.
More resources: openintro.org.
Ansible for DevOpsJeff Geerling
Ansible is a simple, but powerful, server and configuration management tool. Learn to use Ansible effectively, whether you manage one server—or thousands.
Java OOP Done RightAlan Mellor
Object Oriented Programming is still a great way to create clean, maintainable code. But only if you use it right.
This book gives you 25 years of OO best practice, ready to use.
You'll learn to design objects behaviour-first, use TDD to help, then confidently apply Design Patterns, SOLID principles and Refactoring to make clean, crafted code.
Introducing EventStormingAlberto Brandolini
The deepest tutorial and explanation about EventStorming, straight from the inventor.
Discrete Mathematics for Computer ScienceAlexander Shen, Alexander S. Kulikov, Vladimir Podolskii, and Aleksandr Golovnev
This book supplements the DM for CS Specialization at Coursera and contains many interactive puzzles, autograded quizzes, and code snippets. They are intended to help you to discover important ideas in discrete mathematics on your own. By purchasing the book, you will get all updates of the book free of charge when they are released.
Software Architecture for Developers: Volumes 1 & 2 - Technical leadership and communication
2 Books"Software Architecture for Developers" is a practical and pragmatic guide to modern, lightweight software architecture, specifically aimed at developers. You'll learn:The essence of software architecture.Why the software architecture role should include coding, coaching and collaboration.The things that you really need to think about before...
CCIE Service Provider Ultimate Study Bundle
2 BooksPiotr Jablonski, Lukasz Bromirski, and Nick Russo have joined forces to deliver the only CCIE Service Provider training resource you'll ever need. This bundle contains a detailed and challenging collection of workbook labs, plus an extensively detailed technical reference guide. All of us have earned the CCIE Service Provider certification...
Cisco CCNA 200-301 Complet
4 BooksCe lot comprend les quatre volumes du guide préparation à l'examen de certification Cisco CCNA 200-301.
Modern C++ by Nicolai Josuttis
CCDE Practical Studies (All labs)
3 BooksCCDE lab
"The C++ Standard Library" and "Concurrency with Modern C++"
2 BooksGet my books "The C++ Standard Library" and "Concurrency with Modern C++" in a bundle. The first book gives you the details you should know about the C++ standard library; the second one dives deeper into concurrency with modern C++. In sum, you get more than 600 pages full of modern C++ and about 250 source files presenting the standard library...
2 BooksDocker and Kubernetes are taking the world by storm! These books will get you up-to-speed fast! Docker Deep Dive is over 400 pages long, and covers all objectives on the Docker Certified Associate exam.The Kubernetes Book includes everything you need to get up and running with Kubernetes!
Modern Management Made Easy
3 BooksRead all three Modern Management Made Easy books. Learn to manage yourself, lead and serve others, and lead the organization.
The Future of Digital Health
6 BooksWe put together the most popular books from The Medical Futurist to provide a clear picture about the major trends shaping the future of medicine and healthcare. Digital health technologies, artificial intelligence, the future of 20 medical specialties, big pharma, data privacy and how technology giants such as Amazon or Google want to conquer...
Django for Beginners/APIs/Professionals