Functions that should implement an algorithm often fill up with defensive checks: is this count positive, do these timestamps have timezones, does the end come after the start. This series moves those rules into the values themselves, checked once where data enters, so the code behind the boundary can rely on them. Each post works through one example.
Posts in this series
- Let Your Types Carry the Rules - Move repeated input checks into meaningful values, then let the rest of the program do its job. A worked example with counts, timezones, and a report window.
- When Your Types Are Arrays - Named axes help explain tensor code; checked boundaries make those descriptions useful guarantees. A worked example from an attention-head calculation.