4 ms·
This is what is known as new types or opaque types in other languages, right? The runtime representation is that of the "wrapped" type, but they are distinguish
by noelwelsh 2y ago
This is what is known as new types or opaque types in other languages, right? The runtime representation is that of the "wrapped" type, but they are distinguished at compile-time.
- exceptione 2y agoIndeed, this seems to be just a case of newtypes. Newtypes are effective for any kind of value, not just numbers. newtype PostalCode = PostalCode String newtype LicenseKey = LicenseKey String Now you won't be accidentally mixing postal codes and license keys. Every language should support newtypes (and algebraic types).
- Cthulhu_ 2y agoIt's definitely valuable in the domain layer of a business application, Typescript and Go support it as well.