How to use Phantom Types and Existential Types in Production
summary
Shows concrete Haskell code (repo linked) that parses gauge readings, validates them and carries that validation as types: phantom types attach proofs to types; demonstrates non-empty lists, newtypes, and the refined library to express conjunctive predicates. Uses existentials to hide internal pure state while letting IO pass it back: existentials hide pure state from IO. Builds examples: merged redundant gauges, object‑style plugins via existentials, and type‑aligned sequences to enforce launch‑state transitions at compile time.
AI-written summary · about
chapters (9)
- 0:00Start
- 13:09Downstream Code
- 15:06Make Data Correct by Construction
- 23:55Phantom Types
- 34:01Useful Papers on Phantoms
- 38:33Define an Existential Type
- 43:36Object-Oriented Programming
- 49:09Type Aligned Sequences
- 51:35Hiding Intermediate Variables








