Tagged

A tagged type has one or more tags, each with an optional inner type. A value is one of these tags, with a value if needed.

For example, to represent pricing at a theme park, you might have a tagged type with tags Child, Adult, Senior.

Some tagged types may be flexible in their inner types, in which case they are represented using a type variable. For example, the concept of an optional value occurs often: a value may be missing because a survey respondent didn't fill it in, because some sensor data is missing, because a price is unknown, or because the value is not applicable.

Rather than have a separate tagged type for each inner type, e.g. OptionalBoolean, OptionalText, and so on, we have one Optional type that takes a type variable, so we can have Optional(Boolean) or Optional(Text), and so on.

See Alsomaybe