Algebraic Data Type

Noun · Development

Definitions

  1. A composite type formed by combining other types using sum (OR — one of several variants) and product (AND — a combination of fields). Sum types (tagged unions, enums with data) model 'this OR that'; product types (structs, tuples) model 'this AND that'. Enable exhaustive pattern matching and make illegal states unrepresentable.

    In plain English: A way to define types that can be one of several shapes, letting the compiler ensure you handle every possible case.

    Example: "Model the API response as an ADT — Result is either Ok(data) or Error(message), and the compiler forces you to handle both."

Related Terms