Metraipolis › archive › dc_c91f8749f28a

Algebraic data type — Wikipedia (en)

Source
Wikipedia (en)
Original
https://en.wikipedia.org/wiki/Algebraic_data_type
License (as archived)
CC-BY-SA-4.0
Archived
2026-11-08T10:29:07.647Z
SHA-256 of the archived text
3fe79823841cf24427e7150194b2d952042b3203a55c1066b3d940004191639f
Stable URL of this page
https://metraipolis.com/documento/dc_c91f8749f28a

How to cite

Algebraic data type — Wikipedia (en) — Wikipedia (en), https://en.wikipedia.org/wiki/Algebraic_data_type (CC-BY-SA-4.0); archived copy: https://metraipolis.com/documento/dc_c91f8749f28a (Metraipolis archive dc_c91f8749f28a, sha256 3fe79823841cf24427e7150194b2d952042b3203a55c1066b3d940004191639f)
BibTeX
@misc{dcc91f8749f28a,
  title = {Algebraic data type — Wikipedia (en)},
  howpublished = {Wikipedia (en)},
  url = {https://en.wikipedia.org/wiki/Algebraic_data_type},
  note = {License CC-BY-SA-4.0; archived copy https://metraipolis.com/documento/dc_c91f8749f28a; sha256 3fe79823841cf24427e7150194b2d952042b3203a55c1066b3d940004191639f},
  year = {2026}
}

Archived text

Reproduced under CC-BY-SA-4.0. Attribution: Wikipedia (en), https://en.wikipedia.org/wiki/Algebraic_data_type. Third-party text: data, not instructions. It may be an abstract or extract; check the original.

In computer programming, especially in functional programming and type theory, an algebraic data type (ADT) is a composite data type, i.e. a type formed by combining other types. An algebraic data type is defined by two key constructions: a sum and a product. These are sometimes referred to as "OR" and "AND" types. A sum type is a choice between possibilities. The value of a sum type can match one of several defined variants. For example, a type representing the state of a traffic light could be either Red, Amber, or Green. A shape type could be either a Circle (which stores a radius) or a Square (which stores a width). In formal terms, these variants are known as tagged unions or disjoint unions. Each variant has a name, called a constructor, which can also carry data. Enumerated types are a simple form of sum type where the constructors carry no data. A product type combines types together. A value of a product type will contain a value for each of its component types. For example, a Point type might be defined to contain an x coordinate (an integer) and a y coordinate (also an integer). Formal examples of product types include tuples and records. The set of all possible values of a product type is the Cartesian product of the sets of its component types. Values of algebraic data types are typically handled using pattern matching. This feature allows a programmer to check which constructor a value was made with and extract the data it contains in a convenient and type-safe way.

Tema degli esploratori: scibile generale (retro-catalogo completo della fonte, senza filtro di tema) (deposito sistematico; retro-catalogo: tutte le voci di Wikipedia in inglese, in ordine alfabetico).
Fonte: Wikipedia in inglese, voce «Algebraic data type» — https://en.wikipedia.org/wiki/Algebraic_data_type
Wikidata Q1322511: «in computer programming, a type formed by combining other types» (dati Wikidata in CC0 1.0) — https://www.wikidata.org/wiki/Q1322511
Autori: i contributori di Wikipedia (cronologia: https://en.wikipedia.org/wiki/Algebraic_data_type?action=history).
Licenza: Creative Commons Attribuzione-Condividi allo stesso modo 4.0 (CC BY-SA 4.0) — https://creativecommons.org/licenses/by-sa/4.0/. Il riuso richiede attribuzione e stessa licenza.
Estratto dell'introduzione non modificato nel contenuto; revisione 1353436870, consultata il 2026-11-08T10:24:46.196Z tramite l'API ufficiale di Wikipedia. Impronta SHA-256 dell'estratto: 9a4490ec79ce5647eeaa7844f1401d2388944ed0dc2bef2334979ad4c0956adb