Preface
Introduction
- Functional vs. Procedural
- Object-Oriented Code
- Functional Style? Functional Language?
- Type Systems
- What to Expect
- Part One
Pure Functions
- Define “Pure”
- Composing Functions
- Binary Functions
First Class Functions
- Anonymous Functions
- Closure Objects
- Short Lambdas
- Object Binding
Memoization
Currying
Mapping
Filter
Reducing
Concatenation
Recursion
- Recursion
Immutable Value Objects
- What PHP Does
- Making It Immutable
- Objects, Functionally
- Evolvable Objects
- Dependencies
- Entity Objects
- Intra-Function Immutability
- Part Two
Category Theory
- What Is a Category?
- Objects
- Some Definitions
- Structure
- Let’s Get Meta
- Isomorphism
- Monoids
Categories in Code
- Converting Structure
- Function Objects
Fun With Functors
- Combining Functors
- Monads in Programming
- Anatomy of a PHP Monad
Algebraic Data Types
- Products
- Product Types in PHP
- Coproducts
- Coproducts in PHP
- Part Three
Handling Null
- The Problem
- The Example
- The Category Theory Solution
- The Programming Solution
- An Alternate Implementation
- A Note on Types
Either/Or and Error Handling
- The Problem
- The Example
- The Category Theory Solution
- The Programming Solution
- Either Either?
Tracking Data
- The Problem
- The Example
- The Category Theory Solution
- The Programming Solution
Combining Monadic Behavior
- The Example
- The General Approach
- Binding
- The Lexers
- Testing
- Analysis
- Being Lazy
- Part Four
Features of Functional Languages
- Auto-Currying
- Recursion Optimization
- Isomorphic Optimization
- Function Composition
- Function Naming
- Generics
- Callable Types
- Comprehensions
- Integrated Optionals
- Optional Chaining
- A Native Bind Operator
- Enumerated Types
When to Go Functional
- Avoid Global State
- Make Pure Functions
- Isolate IO
- List Application
- Embrace Value Objects
- Embrace Functions as Values
- Make Single-Method Callable Services
- Think in Terms of Pipelines and Data Flow
- Use Maybe and Either for Error Handling
- Don’t Overdo It
Further Resources
- Books
- Videos
- Papers
