4 ms·
Sounds a bit like Haskell's newtype and its class derivation. Using single-member structs (as explained in [0]) gets you the basic idea, but that's still missi
by crote 8y ago
Sounds a bit like Haskell's newtype and its class derivation.
Using single-member structs (as explained in [0]) gets you the basic idea, but that's still missing the automatic lifting of the functions of your underlying element. I'm not sure if there is a sane way to do this given the current ecosystem. Perhaps a syntax like `newtype Celsius = int using std::{+, -, abs}` would work?
[0]: https://blog.nelhage.com/2010/10/using-haskells-newtype-in-c/ https://blog.nelhage.com/2010/10/using-haskells-newtype-in-c...
- jeffdavis 8y agoIn Rust, using the newtype pattern is fairly common, but doesn't have explicit support. It's typically done as a single-member tuple. Maybe support will be added later?