Pragmatic Type-Level Design (PTLD E-Book)
$35.00
Minimum price
$40.00
Suggested price

Pragmatic Type-Level Design

Practical introduction into type-level programming: design principles, design patterns, methodologies, approaches

About the Book

Pragmatic Type-Level Design is a groundbreaking exploration of type-level programming. Unlike other books flirting with a type system and mathematics, this book emphasizes practical applications: best practices, use cases, design patterns, principles, and application architectures universal to various statically typed languages, such as Scala, Rust, Haskell, C++, OCaml and F#. The model language is Haskell, but there is the Rosetta Stone part with the same ideas translated to Scala 3 and Rust.

The book is approachable to mere developers like myself. It is engaging, systematic, full of fun examples, and well-written. It is academism-free. You won’t find anything related to Category Theory, Type Theory, or Abstract Algebra in it. There is no math at all. The book proves that heavy math concepts are unnecessary to benefit from type-level programming.

With its focus on practical outcomes and real-world business needs, Pragmatic Type-Level Design is a must-read for software architects, functional programmers, and engineers who want to elevate their designs beyond the value level. This book teaches the how of type-level programming and the why, ensuring readers can make informed, rational design decisions in their projects.

Book topics:

Type-level design, type-level eDSLs, type-level interfaces, correctness, complexity of solutions, Inversion of Control, domain modeling, application architectures, actor model, testing

GitHub repo: Pragmatic-Type-Level-Design

  • Share this book

  • Categories

    • Software Engineering
    • Haskell
    • Functional Programming
    • Software Architecture
  • Feedback

    Email the Author(s)

About the Author

Alexander Granin
Alexander Granin

International speaker, researcher, author

Expert Haskell and C++ developer

Software architect, team lead

Haskell consultant

Author of the book "Functional Design and Architecture"

Table of Contents

  • Part I The basics of type-level software design
    • 1 Emergent type-level design
      • 1.1 Approaching the type-level design
        • 1.1.1 Types and values
        • 1.1.2 Pragmatic Type-Level Design
        • 1.1.3 Typed Forms diagrams
      • 1.2 The foreshadowing of type-level design
        • 1.2.1 Basics of generics
        • 1.2.2 Basics of type classes
        • 1.2.3 Design principles
        • 1.2.4 Basics of type-level literals
      • 1.3 Summary
    • 2 Use case: simple extensibility
      • 2.1 Extensibility
        • 2.1.1 Extensibility mechanisms
        • 2.1.2 Extensibility requirement
        • 2.1.3 Extension points
      • 2.2 Basically extensible application
        • 2.2.1 Type class interface
        • 2.2.2 Heterogeneous storage problem
        • 2.2.3 Valuefication and existentification
        • 2.2.4 Valuefied storage
        • 2.2.5 Existentified storage
      • 2.3 Summary
    • 3 Use case: genericity and customization
      • 3.1 Type-level genericity
        • 3.1.1 Empty ADTs
        • 3.1.2 Type applications
        • 3.1.3 Ordinary and specific kinds
        • 3.1.4 Custom type-level ADTs and kinds
        • 3.1.5 Type-level lists
      • 3.2 Type-level customization
        • 3.2.1 Case-driven design methodology
        • 3.2.2 Customizable type-level eDSL
      • 3.3 Summary
    • 4 Use case: enforcing correctness
      • 4.1 Correctness is about meaning
        • 4.1.1 Type-safe vs correct
        • 4.1.2 Type-level vs correct
      • 4.2 Static referential integrity
        • 4.2.1 Strengthening the domain model
        • 4.2.2 Static and volatile domain notions
        • 4.2.3 Static operational integrity
        • 4.2.4 Type-level validators
        • 4.2.5 Static structural integrity
      • 4.3 Summary
  • Part II Architecturing type-level applications
    • 5 Application architecture
      • 5.1 Approaching software architecture
        • 5.1.1 Architecture levels
        • 5.1.2 Double Usage Assessment practice
        • 5.1.3 Two applications, same architecture
      • 5.2 Application structure
        • 5.2.1 Layered architecture
        • 5.2.2 Project structure
        • 5.2.3 Organizing type-level code
        • 5.2.4 Application layer
      • 5.3 Summary
    • 6 Components design
      • 6.1 Static and dynamic domain models
        • 6.1.1 Separate type-level and value-level models
        • 6.1.2 Granular Type Selector design pattern
        • 6.1.3 Interpretation of static and dynamic models
        • 6.1.4 Static materialization
        • 6.1.5 Data Transfer Objects and serialization
      • 6.2 Two functional interfaces
        • 6.2.1 Properties of a true interfacing mechanism
        • 6.2.2 Type class versus Free monad
        • 6.2.3 Free monad interface
        • 6.2.4 Type class interface and the Dynamic Payload design pattern
      • 6.3 Summary
  • Part III Advanced type-level design
    • 7 Use case: type-level object-oriented programming
      • 7.1 Multiparadigm approach
      • 7.2 Glimpse of typed object-oriented programming
        • 7.2.1 Zeplrog: the concept
        • 7.2.2 The Expression Problem
      • 7.3 Type-oriented object model
        • 7.3.1 Property model
        • 7.3.2 Static materialization and dynamic instantiation
        • 7.3.2 Typed-Untyped design pattern
      • 7.4 Summary
    • 8 Use case: advanced extensibility
      • 8.1 Advanced type-level design and extensibility
        • 8.1.1 Domain modeling with empty parametrized ADTs
        • 8.1.2 Type-level interfaces
        • 8.1.3 Universal evaluation mechanism
        • 8.1.4 Advanced extensibility and the Expression Problem
        • 8.1.5 Type-level combinatorial eDSLs and lambdas
      • 8.2 Summary
  • Part IV Rosetta Stone
    • Rosetta Stone Chapter 1 Rust
      • RSC.1.1 Value-level and mixed-level features
        • RSC.1.1.1 Newtype
        • RSC.1.1.2 ADTs
        • RSC.1.1.3 Traits, interfaces, and type classes
        • RSC.1.1.4 Empty ADTs
        • RSC.1.1.5 Proxy types and phantom types
        • RSC.1.1.6 Simple generics
        • RSC.1.1.7 Parameterized ADT
      • RSC.1.2 Type-level features
        • RSC.1.2.1 Type-level literals
        • RSC.1.2.2 Custom kinds and type-level ADTs
        • RSC.1.2.3 Type-level lists
        • RSC.1.2.4 Type-level strings
        • RSC.1.2.5 Type families and associated types
      • RSC.1.3 Type-level interfaces, extensibility, and domain modeling
        • RSC.1.3.1 Advanced kind system
        • RSC.1.3.2 Existential wrappers and implementation types
        • RSC.1.3.3 Evaluation mechanism
        • RSC.1.3.4 Kinded type-level lists
      • RSC.1.4 Integrity validation
        • RSC.1.4.1 Type equality
        • RSC.1.4.2 Type selection mechanism
        • RSC.1.4.3 Static and volatile domain notions
        • RSC.1.4.4 Integrity validators
        • RSC.1.4.5 Static assert
    • Rosetta Stone Chapter 2 Scala 3
      • RSC.2.1 Value-level and mixed-level features
        • RSC.2.1.1 Newtype (opaque types)
        • RSC.2.1.2 ADTs
        • RSC.2.1.3 Traits and type classes
        • RSC.2.1.4 Empty ADTs, parameterized ADTs, and proxies
      • RSC.2.2 Type-level features
        • RSC.2.2.1 Type-level literals
        • RSC.2.2.2 Custom kinds and type-level ADTs
        • RSC.2.2.3 Type-level lists
        • RSC.2.2.5 Type families and match types
      • RSC.2.3 Type-level interfaces, extensibility, and domain modeling
        • RSC.2.3.1 Type-level interfaces and existential wrappers
        • RSC.2.3.2 Kinded type-level lists
        • RSC.2.3.3 Evaluation mechanism
      • RSC.2.4 Integrity validation
        • RSC.2.4.1 Integrity validators and type comparison
        • RSC.2.4.2 Standalone and integrated validators
  • Appendices
    • Appendix A Typed Forms diagrams
      • A.1 General conventions
      • A.2 Regular types, pairs, aliases, lists
      • A.3 Simple ADTs
      • A.4 Parametrized types
      • A.5 Generics specification syntax
      • A.6 Type classes and instances
      • A.7 Kinds
      • A.8 Type promotion
      • A.9 Simple type families and the HKD template
    • Appendix B Existential Fight Club
      • B.1 Haskell, existentification
      • B.2 Haskell, valuefication
      • B.3 Rust, existentification
      • B.4 Rust, valuefication
      • B.5 C++, object-oriented variant
      • B.6 C++, valuefication
      • B.7 Scala 2, existentification with implicits
    • Appendix C The Mythologized Correctness
      • C.1 Type safety
        • C.1.1 Generic type safety
        • C.1.2 Descriptive type safety
      • C.2 Technical correctness
        • C.2.1 Correctness of data structures and algorithms
        • C.2.2 Correctness of data models
        • C.2.3 Correctness of languages
        • C.2.4 Conclusion
    • Appendix D Extensible value definition model in the Zeplrog project
      • D.1 Trichotomy: extensibility, type safety, and simplicity
      • D.2 Extensible value model of Zeplrog
        • D.2.1 Properties and scripts
        • D.2.2 Variables, values, and tags
        • D.2.3 Extensibility with open type families
    • Appendix E Event-based architecture in the Minefield game
      • E.1 Minefield application architecture
        • E.1.1 Event-based actor model
        • E.1.2 Minefield type-level domain model
        • E.1.3 Domain-level noun-verb extensibility
      • E.2 Minefield application implementation
        • E.2.1 The MVar request-response pattern
        • E.2.2 Events and queues
        • E.2.3 Actor model implementation

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $14 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub