3 ms·
Dependent types to the rescue! Dependent types are nice, but much what the grandparent wants can be achieved fine with normal types. E.g. in Haskell, define th
by danieldk 13y ago
Dependent types to the rescue!
Dependent types are nice, but much what the grandparent wants can be achieved fine with normal types. E.g. in Haskell, define the Longitude type and some helper functions
newtype Longitude = Longitude Double
fromDouble :: Double -> Maybe Longitude
...
And don't export the Longitude constructor to maintain invariants. Obviously, the same can be done in OO languages that allow you to hide members, C (via opaque pointers), etc.