4 ms·
The idea is to disallow altogether construction of invalid states, so you don't even need to write logic to catch bad data instances, or "convert integers to st
by emmanueloga_ 6y ago
The idea is to disallow altogether construction of invalid states, so you don't even need to write logic to catch bad data instances, or "convert integers to strings" (god forbid :-p). [1] gives a typical example of how this modeling may look like.
I think something like typedefs could be great in providing this kind of data modeling capabilities in languages where it ADTs are more tedious to write by hand.
1: https://fsharpforfunandprofit.com/posts/designing-with-types-making-illegal-states-unrepresentable/#making-illegal-states-unrepresentable https://fsharpforfunandprofit.com/posts/designing-with-types...