In
computer science, a
tagged union, also called a
variant,
variant record,
discriminated union,
disjoint union, or
sum type, is a
data structure used to hold a value that could take on several different, but fixed, types. Only one of the types can be in use at any one time, and a
tag field explicitly indicates which one is in use. It can be thought of as a type that has several "cases," each of which should be handled correctly when that type is manipulated. Like ordinary
unions, tagged unions can save storage by overlapping storage areas for each type, since only one is in use at a time.