An approachable, well-written, practice-oriented, academism-free guide into programming with types. How to build useful real-world type-level programs with low complexity and low risks.
Pragmatic Type-Level Design is a book about programming in types, about the discipline of Software Design, lifted onto the level of types, and type-level approaches useful in real practice.
I aim to provide a well-written and well-structured source of knowledge about type-level design. I’m not only talking about type-level features but also providing a reasoning framework for making the narrative complete and comprehensive. The central philosophy of this book - pragmatism - is used to build a practice-first methodology on how to approach types and not drown in the related complexity. The type-level design is difficult on its own, type-level features in various languages are difficult as well, and there is no need to raise the learning bar even more.
The book will be useful for developers who want to start doing real things on the type level.
If you liked my FDaA book, you’ll find PTLD enlightening and insightful as well.
Type-level programming has been around for a while, with many languages boasting rich type systems. It’s a domain beloved by many, especially in Haskell, where types are one of the language’s most compelling features. Haskell developers often gravitate toward the mathematical foundations of types, like Category Theory and Type Theory. But as I sought to improve my understanding of types, I found myself constantly struggling, frustrated, and confused. The academic focus on math didn’t provide the answers I was looking for. As a pragmatist, I wanted a clear, practical framework for software design with types—from design principles to implementation details. Yet, most resources left my questions unanswered. They were either overly academic or too fragmented to offer a coherent view. And while type-level programming is challenging by nature, it’s even more so in Haskell due to the disjointed and complex nature of the existing materials. These resources often felt like folklore or scattered wisdom rather than structured, practice-oriented knowledge.
This is why I want to create this book. With Pragmatic Type-Level Design, my goal is to provide a complete, practical, and organized discipline for type-level programming, free from unnecessary academic abstractions and focused on real-world application. I know I can do it—I’ve already addressed the lack of practical materials in software engineering and functional programming with Functional Design and Architecture. I even developed a methodology called Functional Declarative Design, and its success exceeded my expectations.
Good old Haskell 2010 introduces a lot of type-level features. Type definitions, type classes, type variables, constraints, kinds, phantom types, and algebraic data types. With dozens of modern GHC extensions, it becomes orders of magnitude more powerful. Type-level literals, type families, multi-parameter type classes, generalized algebraic data types, different options for type-level polymorphism, et cetera, et cetera – it’s too long to enumerate all these tools, what to say about the explosion of all possible ways to combine them. This is why I believe the field of type-level programming is a pure art, yet everyone does it differently. We’re going turn this art into engineering so it can be applied to many various tasks uniformly. But we have to learn the fundamentals first. I’m about to demonstrate two important features: type classes and type-level literals, which are at the heart of type-level design. We’ll introduce many other type-level features as needed.
Book topics: type-level design, type-level eDSLs, correctness, complexity of solutions, Inversion of Control and Dependency Injection, domain modeling, type-level functional interfaces, design of business logic, interaction with impure subsystems, application architectures & design patterns, testing.