3 ms·
>Types that don't actually do any constraining are useless. Exactly! I can make CartId/ProductId/WhateverId types that are just wrappers around String. But th
by catern 8y ago
>Types that don't actually do any constraining are useless.
Exactly!
I can make CartId/ProductId/WhateverId types that are just wrappers around String. But that's not actually using the type system to enforce correct behavior. Nothing in the type system prevents me from violating the invariants of my application.
I would only actually be using the type system, if my types were actually constrained so that only valid CartIds, that refer to real Carts, could be created. Then I would actually have a useful invariant, which the type system guarantees cannot be violated. (inasmuch as the validation step when creating CartIds is correct)
- jpitz 8y agoBut aren't you then constrained until the end of time to ensure that cart ids and product ids are entirely disjoint? That's way too coupled for my little brain.