Thinking Functionally in PHP

Thinking Functionally in PHP

Larry Garfield
This is a sample of the book's content.Buy on Leanpub

Table of Contents

Preface›

  • 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
Thinking Functionally in PHP/Part Four

Part Four

This content is not available in the sample book. The book can be purchased on Leanpub at http://leanpub.com/thinking-functionally-in-php.

Up next

Features of Functional Languages

In this part

  • 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