Skip to content

Type-Driven Design: section map for agents

Main map · This map · Section overview

Using the type system as a design tool: modeling states, workflows, errors, invariants and boundaries so that types record what has been established and which operations are legal.

All documents in this collection are listed below, grouped by subsection.

Status labels: Canonical = preferred starting point for its topic; Draft = provisional working material; Archived = preserved history. Unlabeled documents have no assigned status.

Documents

  • Type-Driven Design Reading Paths — Books, papers and courses on type-driven design grouped by goal: a map that lists each source once with what it is for, then reading paths for practical design, runtime evidence and type theory.

Type-Driven Design: Architecture

Organising a typed domain into a program: functional domain modeling with algebras and interpreters, ways to wire them (Reader, tagless final, free monads, ZIO, algebraic effects), and declarative design.

  • Declarative Specifications and Engines — Declarative specifications and execution engines, four senses of "declarative", the connection to functional programming, DSLs, model-driven engineering and ontologies, and key contributors.
  • Effects, Interpreters and Wiring — Supplying interpreters for domain algebras and deciding where effects happen: Reader and Kleisli, free monads, ZIO and algebraic effects, compared by what their types reveal, plus initial and final embedded DSLs.
  • Functional Domain Modeling — A domain model built from pure functions over domain types, with side effects kept out of the domain logic and behavior described as algebras with separate interpreters.
  • Tagless Final — Tagless final as a typed encoding of algebras and interpreters: its origin in typed EDSLs, the expression problem, Volpe's and Parsons' rules for production code, and two critiques.

Type-Driven Design: Domain Modeling

Modeling a domain so that its types state which values and states can exist: type-first design, newtypes, algebraic data types, illegal states made unrepresentable, values and entities, errors, workflows and state machines.

  • Algebraic Data Types — Combining types with AND (product types) and OR (sum types), counting a type's values as a design check, and sum types versus tagged classes and class hierarchies, with Wlaschin, Kurt, Milewski, Parsons, Płachta, Bloch and Ghosh.
  • Domain Modeling with Types — An overview of modeling a domain with types, following Wlaschin and Kurt: type-first design, how the vocabulary translates across languages, values, entities and aggregates, and errors as values.
  • Making Illegal States Unrepresentable — Designing types so that a value breaking a business rule can't be built: verified emails, "at least one of", connascence of value, booleans, a flag plus an optional value, and behaviour as data.
  • Newtypes and Simple Values — Primitive obsession and the newtype pattern, Scala value classes and opaque types, and simple values whose constructors enforce a rule.
  • Workflows and States — Modeling a value that moves through states: a workflow as a function type, one type per state, state machines, typestate encodings with phantom types, and long-running workflows.

Type-Driven Design: Foundations

What a type system is and proves, the dimensions along which type systems differ, inference, types as propositions, and how to decide what belongs in the types at all.

  • Dimensions of Type Systems — The axes along which type systems differ: static, dynamic and gradual checking, safety and what "strong" means, and nominal versus structural equivalence.
  • Type Inference — Type inference as ergonomics rather than a guarantee: what inference saves, where it stops (System F, type families, refinement qualifiers), and why signatures are still worth writing.
  • Type Systems — What a type system is, starting from Pierce's definition: soundness, conservativity, the four parts of the definition, and what type systems buy, from early error detection to documentation and efficiency.
  • Types as Propositions — The Curry-Howard reading of types: types as propositions and programs as proofs, what it means for ordinary code, and how far each kind of type system takes it.
  • What Belongs in the Type System — Choosing between types, contracts, runtime checks and tests: what makes a good type-system target, a decision procedure, where types stop matching reality, and the cost of stronger guarantees.

Type-Driven Design: Parsing and Evidence

Turning untrusted input into types that carry what was checked: parse, don't validate, how strong a parsed type's evidence is, and the trust boundaries where data enters and leaves.

  • How Strong the Evidence Is — How much a parsed type guarantees: smart constructors and newtypes, constructive versus encapsulated types, names that are not type safety, constructors that bypass the check, and evidence without runtime cost.
  • Parse, Don’t Validate — Alexis King's principle: parse input at the boundary into types that keep what was checked, instead of validating and passing on weak types. Shotgun parsing, partial functions made total, and where parsing gets harder.
  • Types at the Boundary — Where the trust boundaries are, how domain types map to the shapes that cross them (DTOs, rows and messages), and what happens when those shapes change while old data stays where it was written.

Type-Driven Design: Stronger Type Systems

Type systems that say more than ordinary ones: refinement types and how they are checked, what each language offers, the step to dependent types, and the Scala type system's features for correctness.

  • Refinement Types — Refinement types as base types restricted by predicates: why bother, how SMT-based checking and Liquid inference work, and the limits of the approach.
  • Refinement Types by Language — What Python, TypeScript, Haskell, Rust, Ada and Scala offer in place of, or as, refinement types, and Scala's terminology trap: its own "refinement types" mean something else.
  • Scala Type System — The Scala type features type-driven design relies on: abstract type members, nominal and structural subtyping, union and intersection types, path-dependent types, multiversal equality and contracts.
  • Towards Dependent Types — The progression from ordinary types through refinement types to dependent types, the two senses of "dependent", and how Haskell, Scala and Pierce's Dependent ML approach it.

Use the main map to explore other collections. Descriptions come from note metadata or the page summary; working notes and versions retain their own scope.