A ghost sitting in front of a laptop

Phantom Types

UPDATE Wed 24th, 2024: This article was originally called “Nominal Types”. A few people on lobste.rs and r/programming pointed out that naming this Nominal Types is incorrect. A better description would be Phantom Types or maybe Tagged Types. Quick overview of using nominal types to encode semantic differences between types in an efficient and elegant way The Problem Let’s say we’re writing a program with various types of IDs: user IDs, group IDs and document IDs....

January 22, 2024 · 4 min · 850 words · dsp