An example of what you can implement on top of branded types that I want to share with fellow hackers:<p>- currencies<p>You may have some sort of integer representing the number of cents of some currency and you want to avoid doing operations between the wrong currencies (such as adding euros and pesos).<p>You can create branded types and functions that work on those Euro branded numbers and then decide how to do math on it. Or numbers representing metals and such.<p>It's useful in other scenarios such as a, idk, strings, you could theoretically brand strings as idk ASCII or UTF-8 or the content of an http body to avoid mixing those up when encoding but I want to emphasize that often many of those hacks are <i>easier</i> to be handled with stuff like dictionaries or tagged unions.<p>An example of what can be achieved with similar approaches (beware it's oriented for people that are at least amateur practitioners of functional programming) is Giulio Canti's (an Italian mathematician and previously author of t-comb, fp-ts, io-ts, optic-ts, and now effect and effect/schema), the money-ts library:<p><a href="https://github.com/gcanti/money-ts">https://github.com/gcanti/money-ts</a>