Loom

A blog engine that just works. One binary, no setup, no dependencies.

~/  20 posts

Building a Type-Safe Protocol — The Grand SynthesisMar 30 22.8K

We combine every technique from this series — algebraic types, pattern matching, phantom types, typestate, concepts, compile-time data, parametricity, linear logic, F-algebras — to build a compile-time verified protocol where violations are type errors, not runtime surprises.

--c++20 --type-theory --typestate --protocols --compile-time --capstone
Recursive Types and Fixed Points — The Algebra of DataMar 29 16.8K

A list contains lists. A tree contains trees. How do you define a type in terms of itself? Fixed points, F-algebras, and catamorphisms — the formal machinery behind every fold, every visitor, and every recursive data structure.

--c++20 --type-theory --recursive-types --fixed-points --f-algebras --catamorphisms
Substructural Types — When Resources Are Not FreeMar 28 16.8K

Classical logic lets you copy and discard premises freely. Remove those abilities and you get the logic of resources — linear, affine, relevant, ordered. RAII, move semantics, and unique_ptr are fragments of this theory. C++ is a substructural language and doesn't know it.

--c++20 --type-theory --linear-types --affine-types --raii --move-semantics
Parametricity — Theorems for FreeMar 27 42.0K

If a function works for any type and never inspects it, its behavior is constrained by the type signature alone. You get theorems without proofs. This is parametricity — and it explains why phantom types, generic algorithms, and templates are more powerful than they look.

--c++20 --type-theory --parametricity --free-theorems --polymorphism
Compile-Time Data — When Values Become TypesMar 26 14.4K

C++20 lets values enter the type system. This is the gateway to dependent types — Pi types, Sigma types, and the calculus of constructions. The compiler becomes a staged computation engine.

--c++20 --type-theory --constexpr --nttp --compile-time --dependent-types
Putting It All Together — The Full PipelineMar 25 27.6K

Twelve posts of theory. Now we build. A complete, compilable, interactive terminal renderer — style interning, 8-byte cells, cell-level diffing, transition cache, synchronized output, threaded compositor. Copy it. Compile it. Resize your terminal. Watch zero flicker.

--c++23 --full-pipeline --demo --terminal-rendering --compositor --double-buffering --claude-code
Concepts as Logic — Propositions, Proofs, and PredicatesMar 25 13.2K

C++20 concepts are propositions in intuitionistic logic. Requires-expressions are constructive proofs. Subsumption is modus ponens. This is natural deduction, hiding in your compiler.

--c++20 --type-theory --concepts --logic --curry-howard --natural-deduction
Typestate Programming — When Types Remember What HappenedMar 24 14.4K

States as types. Transitions as functions that consume and produce. Grounded in linear logic — where every resource must be used exactly once — typestate turns protocol violations into compile errors.

--c++20 --type-theory --typestate --state-machines --linear-logic --protocols
Thread Safety — The CompositorMar 23 8.4K

The spinner thread and the main thread both want stdout. They can't have it. The Compositor is the bouncer: one lock, one writer, zero corruption. Plus the self-pipe trick, mutable regions, and why the mutex must cover the write() syscall.

--c++23 --compositor --mutex --thread-safety --signal-handling --self-pipe --claude-code
Phantom Types — Making the Compiler See What Isn't ThereMar 23 13.2K

A phantom type parameter exists only in the type system — it carries no data, occupies no memory, and vanishes in the binary. Parametricity guarantees it works. Representation independence makes it free.

--c++20 --type-theory --phantom-types --templates --zero-cost --parametricity
Pattern Matching — Deconstructing Values by ShapeMar 22 31.2K

Pattern matching is the elimination form for algebraic types — the way you take apart what introduction rules put together. Exhaustiveness, nested patterns, guards, refutability, and the deep reason why the compiler insists you handle every case.

--c++20 --type-theory --pattern-matching --elimination-rules --exhaustiveness --case-analysis
Double Buffering and Frame LifecycleMar 21 8.4K

Two buffers. Swap every frame. Clear, render, replay, diff, emit, swap. The complete lifecycle of a single frame, from event trigger to terminal update, in ~230 microseconds.

--c++23 --double-buffering --frame-lifecycle --synchronized-output --event-driven --claude-code
Sum Types and Product Types — The Algebra of C++ TypesMar 21 54.0K

Types form a semiring. Products multiply, sums add, and the distributive law lets you factor types like polynomials. Initial algebras, catamorphisms, and the deep reason why std::visit is the only operation you need.

--c++20 --type-theory --variant --tuple --algebraic-types --initial-algebras
A Program Is a Theory — Foundations of Type-Theoretic C++Mar 20 24.0K

Type judgments, formation rules, Curry-Howard, and the lambda cube — real type theory, made concrete in modern C++. A program is a formal system, and the compiler is its first reviewer.

--c++20 --type-theory --compile-time --design --foundations
Hardware Scroll — Moving Rows Without RewritingMar 19 9.6K

The terminal can shift rows for you. You just have to ask nicely with CSI sequences, and then lie to your own diff engine about what the previous frame looked like. Result: 99% reduction in scroll I/O.

--c++23 --hardware-scroll --csi-sequences --scroll-region --memmove --terminal-rendering --claude-code
Style Transitions — The Transition CacheMar 17 9.6K

The single highest-leverage optimization in the entire pipeline. Computing the minimal ANSI to go from style A to style B, caching it forever, and never computing it again. 30-50% reduction in terminal output with one hash map.

--c++23 --style-transition --ansi-sgr --cache --optimization --terminal-rendering --claude-code
247 Database Queries to Render One Page: The ORM DelusionMar 17 9.6K

Your ORM is quietly sending 247 database queries to render one page. It smiled warmly while loading your entire database into memory one row at a time, like a golden retriever fetching every stick in the park.

--architecture --databases --performance --series
The Diff Engine — Only Paint What ChangedMar 15 10.8K

The heart of the renderer: compare two screen buffers cell by cell, emit the minimal ANSI to transform one into the other. Every optimization upstream exists to make this loop faster. Every optimization here directly reduces bytes to stdout.

--c++23 --diff-engine --ansi-escape --cursor-optimization --damage-rect --claude-code