3 ms·
> "set of explicitly defined states" this is called algebraic data type (https://en.wikipedia.org/wiki/Algebraic_data_type https://en.wikipedia.org/wiki/Algebr
by chii 2y ago
> "set of explicitly defined states"
this is called algebraic data type (https://en.wikipedia.org/wiki/Algebraic_data_type https://en.wikipedia.org/wiki/Algebraic_data_type), and it is the best way, imho, to reduce bugs in code.
By making it easy to pattern match, it reduces the possiblity of producing an invalid state, because at the time of definition, you have to figure out how to get that type (and checked by compiler).