Loom

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

Posts tagged “c++20” (19)

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
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
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
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
Content Loading — From Filesystem and Git to Typed Site DataJan 02 16.8K

How Loom loads blog content from the local filesystem or a remote git repository using the same interface, parses frontmatter and config without dependencies, extracts image dimensions from raw PNG and JPEG bytes, and derives metadata from git history.

--loom-internals --c++20 --content --parsing --git
The HTTP Server — An Epoll Event Loop in 400 LinesDec 26 13.2K

How Loom serves HTTP with a single-threaded epoll event loop, zero-copy request parsing via string_view, pre-serialized wire responses, and a dual write path that avoids allocations on the hot path.

--loom-internals --c++20 --http --networking --epoll
Compile-Time Routing — Zero-Overhead DispatchDec 19 9.6K

How Loom encodes routes as non-type template parameters, analyzes patterns at compile time, and generates an optimal dispatch chain with zero runtime overhead.

--loom-internals --c++20 --routing --constexpr --templates
The Theme Compiler — From ThemeDef to CSSNov 28 10.8K

How Loom compiles typed theme definitions into CSS using pointer-to-member bindings, fold expressions, structural emitters, a full CSS DSL, and component overrides.

--loom-internals --c++20 --themes --css --dsl
The DOM DSL and Component System — HTML as C++ ExpressionsNov 21 12.0K

How Loom turns HTML generation into composable C++ expressions with a fold-based DOM builder, control flow primitives, and a JSX-like component system with theme-overridable slots.

--loom-internals --c++20 --dsl --templates --components