In programming language theory, an algebraic data type (ADT) is a kind of composite type, i.e., a type constructed with multiple primitive data types. There are two main types of ADTs:

  • Sum types — including variant types (like enums).
  • Product types — including tuples or records (also called structs).

Language-specific

Functional programming languages introduce ADTs as first-class notions. Some non-FP languages also allow defining ADTs. For example:

  • Sum types
    • Enum — supported in C++ and Rust. Rust enums are similar to Haskell types, where enums can be a composition of other types.
  • Product types

See also