4 ms·
Are union types the new lambdas?
by FeepingCreature 9y ago
Are union types the new lambdas?
- jstimpfle 9y agoThey seem overused and overpraised. They have their uses, but largely you don't want to mash together different things in a program if you can avoid it. Because it leads to unmaintainable switching code. Alternatives: Have n containers of simple types instead of one container with elements of union types with n alternatives. Sometimes that's not possible because you need to process them in a specific order, but even then you can just keep an additional reference table that references into the n containers. Another alternative would be to make the type an ADT (of course, not always applicable, either).