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/overview

Thinking Functionally in PHP

course_overview

Functional programming in PHP 7.4, with a side of category theory and monads accessible to everyone.

count_parts
·
count_chapters
begin_reading
download
part_count

Preface2 chapters

Begin part ›
  1. Preface

  2. Introduction

part_count

Part One10 chapters

Begin part ›
  1. Pure Functions

  2. First Class Functions

  3. Memoization

  4. Currying

  5. Mapping

  6. Filter

  7. Reducing

  8. Concatenation

  9. Recursion

  10. Immutable Value Objects

part_count

Part Two4 chapters

Begin part ›
  1. Category Theory

  2. Categories in Code

  3. Fun With Functors

  4. Algebraic Data Types

part_count

Part Three4 chapters

Begin part ›
  1. Handling Null

  2. Either/Or and Error Handling

  3. Tracking Data

  4. Combining Monadic Behavior

part_count

Part Four3 chapters

Begin part ›
  1. Features of Functional Languages

  2. When to Go Functional

  3. Further Resources