The book that teaches you to discover leak-free abstractions, and to automatically derive implementations.

About the Book

Hi there. My name is Sandy Maguire and you might know me from my blog where I write about type-level programming in Haskell.

One of purely functional programming's greatest strengths is its powerful abstraction capabilities. We proudly exclaim that our functions are referentially transparent, and because of that, our bugs will always be shallow. And this is often true.

10x is often cited as the magic number beyond which technology is good enough to overcome network effects. I'm personally convinced that functional programming is 10x better than any other paradigm I've tried. But if functional programming is so good, why hasn't it yet taken over the world?

This is a very serious question. If we're right about this, why haven't we won?

Algebra-Driven Design is my answer to this question. Functional programming hasn't taken market share because we collectively don't yet know how to write real applications with it. Abstraction is our language's greatest strength, but all of our "best practices" evangelize writing the same procedural code and use the same techniques as we would anywhere else.

Instead of giving up, this book encourages us to take a heavy focus on designing leak-free abstractions, on understanding programs so well that the code and tests can be largely generated automatically, and on finding performance improvements not via intuition, but through algebraic manipulation of the program's underlying equations. Functional programming affords us so many new possibilities for designing and testing better code, but this information is scattered and lost in ancient journals. I'd like to change that.

What You'll Learn


  • Specifying Laws
  • Equational Reasoning
  • Giving Denotational Semantics
  • Constructors and Observations
  • Algebraic Initial Encodings
  • Immortalizing Model Semantics


  • Property-Based Testing
  • Effective Use of QuickSpec
  • Writing Good Generators
  • Debugging QuickCheck and QuickSpec
  • Interpreting Generated Laws

Intuition For

  • Algebras
  • Monoids
  • Groups
  • Semilattices
  • Annihilation
  • Distributivity
  • Idempotence

Interested, but not sure if it's for you? Read the first few chapters and see what you think!