Using Haskell's 'newtype' in C
Summary
The post shows how to emulate Haskell's newtype pattern in C by wrapping primitive types in small structs and using macros to enforce type safety across memory-management code. It provides concrete examples with physaddr_t, virtaddr_t, and ppn_t, and demonstrates PADDR/KADDR wrappers, performance considerations, and cross-ABI compatibility. The technique aims to reduce bugs from accidentally mixing equivalent representations while maintaining performance.