Functional Programming Strategies
Functional Programming Strategies
Mental models for better code
A book by Noel Welsh
Buy the draft PDF
You'll receive an update with every new version.
The book is currently a draft.<br>You can read a free sample,<br>or join the mailing list to hear when it's released.<br>If you have suggestions or spot a mistake, please<br>open an issue.
About the Book
Most programming books teach syntax; Functional Programming<br>Strategies teaches you how to think.<br>The right mental models lead naturally to better code,<br>and functional programming's theoretical foundations provide exceptionally<br>useful mental models—ones that scale from simple functions to complex<br>systems.<br>Over 25 years of professional programming I've refined a mental toolkit<br>that I call functional programming strategies.<br>These strategies form the core of the book.<br>For example, “types as constraints” is the<br>strategy of representing semantic constraints in the type system, while<br>“following the types” is the strategy of using type information to guide<br>the implementation.<br>Every strategy is illustrated with practical case<br>studies showing how they apply to real code.
To get the most from Functional Programming Strategies you<br>should be proficient with a programming language and ready<br>to dive into where theory and practice meet. This is not an<br>introductory programming book, but one on the deep concepts and<br>connections behind programming. The book's examples use Scala—its expressivity<br>makes it easy to demonstrate the strategies, while its industry adoption<br>means you can apply these techniques immediately in production code.<br>The strategies, however, are language agnostic and translate to other<br>modern typed languages, such as Rust, Kotlin, OCaml, or Typescript.
If you are after a systematic way to create code, rather than relying<br>on trial and error,<br>buy the draft PDF<br>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,<br>how to choose between the two based on extensibility<br>requirements, and how to translate from one to the<br>other.
Practical Examples
Real-world code examples covering core programming<br>concerns such as error handling and complete systems<br>such as a stream-processing engine.
Type Classes
Learn how type classes provide a novel form of extensibility.<br>Understand core type classes such as monoids, applicative functors, and monads, and how to use<br>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<br>principle and as a tool for program design.<br>Explore the dualities between data and codata, direct-style and continuation-passing style, and<br>more in practical case studies.
Interpreters
Learn how interpreters can be used to handle effects in a functional style,<br>and see the major implementation strategies and approaches to optimization.<br>Solve the “expression problem” with extremely flexible tagless final style<br>interpreters.
A Whole Lot More
This just scratches the surface of what's in the book.<br>At over 500 pages it's a comprehensive reference for all the major concepts and techniques used<br>by experts.
Read the free preview<br>for the full table of contents and sample chapters.
What Readers Are Saying
An approachable classic introduction now updated to Scala 3 with new systematic parts of how to think about the underlying problems.<br>The new "meta" parts are a real enhancement. Parts of it I have seen before but never in such a systematic fashion.<br>I think this is a great book!<br>Highly recommended!
Carsten Ihlemann, PhD, Senior Engineer at aruna GmbH
I turned to the book to improve the design of a research project I was<br>developing in Scala, which I wanted to redesign for better results. I found the<br>book very clear in its explanations and exercises.
Professor Manuel Gómez Olmedo, Department of Computer Science and Artificial Intelligence, University of Granada
A highly readable and insightful guide that deepened my understanding of functional programming and improved how I write Scala code.
Rob Knapen, Research Engineer, AI for Agriculture
Stay Updated
The book will be launched in 2026. Get notified when it launches and<br>receive exclusive updates. We'll never share your email address with<br>anyone else.
Notify Me
Powered by Buttondown.