Functional Programming Strategies

Mental models for better code

You'll receive an update with every new version.

The book is currently a draft. You can read a free sample, or join the mailing list to hear when it's released. If you have suggestions or spot a mistake, please open an issue.

About the Book

Most programming books teach syntax; Functional Programming Strategies teaches you how to think. The right mental models lead naturally to better code, and functional programming's theoretical foundations provide exceptionally useful mental models—ones that scale from simple functions to complex systems. Over 25 years of professional programming I've refined a mental toolkit that I call functional programming strategies. These strategies form the core of the book. For example, “types as constraints” is the strategy of representing semantic constraints in the type system, while “following the types” is the strategy of using type information to guide the implementation. Every strategy is illustrated with practical case studies showing how they apply to real code.

To get the most from Functional Programming Strategies you should be proficient with a programming language and ready to dive into where theory and practice meet. This is not an introductory programming book, but one on the deep concepts and connections behind programming. The book's examples use Scala—its expressivity makes it easy to demonstrate the strategies, while its industry adoption means you can apply these techniques immediately in production code. The strategies, however, are language agnostic and translate to other modern typed languages, such as Rust, Kotlin, OCaml, or Typescript.

If you are after a systematic way to create code, rather than relying on trial and error, buy the draft PDF or sign up to the mailing list to be notified when the book is released.

What You'll Learn

Data and Codata

Learn to represent concepts in code as data or codata, how to choose between the two based on extensibility requirements, and how to translate from one to the other.

Practical Examples

Real-world code examples covering core programming concerns such as error handling and complete systems such as a stream-processing engine.

Type Classes

Learn how type classes provide a novel form of extensibility. Understand core type classes such as monoids, applicative functors, and monads, and how to use them as both code level abstractions and as conceptual tools for program design.

Dualities

See how dualities—bidirectional program transformations—can be used as an organizing principle and as a tool for program design. Explore the dualities between data and codata, direct-style and continuation-passing style, and more in practical case studies.

Interpreters

Learn how interpreters can be used to handle effects in a functional style, and see the major implementation strategies and approaches to optimization. Solve the “expression problem” with extremely flexible tagless final style interpreters.

A Whole Lot More

This just scratches the surface of what's in the book. At over 500 pages it's a comprehensive reference for all the major concepts and techniques used by experts.

Read the free preview for the full table of contents and sample chapters.

Stay Updated

The book will be launched in 2026. Get notified when it launches and receive exclusive updates. We'll never share your email address with anyone else.

Powered by Buttondown.