jargon

Design patterns·Functional ideas that went mainstream

the type says it is exactly one of four things, and the compiler will not let you forget the fourth.

Algebraic data type

Also calledADT, sum type, tagged union, discriminated union

A type built by combining others as products — a record with several fields — or sums — one of several alternatives, each with its own data. The sum half is the one that changes how code is written: modelling a state, a result or a command as a closed set of alternatives makes the impossible combinations unrepresentable. It is the type-level version of the state pattern, and much harder to get subtly wrong.

Commonly confused with