3 ms·
Addendum to my nominal types: For the 'fake' nominal types (you can't put a symbol on a number!) I like to make those fields optional, which makes the type less
by TOGoS 4y ago
Addendum to my nominal types: For the 'fake' nominal types (you can't put a symbol on a number!) I like to make those fields optional, which makes the type less of a lie. "If this number did have a [unit symbol] property, the value would be 'USD'". That will still prevent accidental USD <-> CAD conversion, but allows converting to/from regular numbers without explicit casting.
A pile of thoughts on the subject from back when I first came up with it: http://www.nuke24.net/plog/32.html http://www.nuke24.net/plog/32.html
- triyambakam 4y agoVery cool
- liminal 4y agoThis is really great. I once spent a little time thinking about how to better represent RDF in Type/Javascript. These approaches seem like a good direction to go in. Would love to see these ideas developed further.
- isleyaardvark 4y agoI’ve seen several TS users describe that approach as “branding” (or “flavoring” if it is optional).