| Algebraic Datatype |
Article Index for Algebraic |
Website Links For Algebraic |
Information AboutAlgebraic Datatype |
| CATEGORIES ABOUT ALGEBRAIC DATA TYPE | |
| functional programming | |
| type theory | |
| data types | |
| articles with example visual prolog code | |
| articles with example haskell code | |
|
The most common algebraic data type is a list with two constructors: Nil or for an empty list, and ).Special cases of algebraic types are product types (only one constructor) and enumeration types (many constructors with no arguments). Algebraic types are one kind of constructed type (i.e. a type formed by combining other types). An algebraic data type may also be an Abstract Data Type (ADT) if it is exported from a module without its constructors. Values of such a type can only be manipulated using functions defined in the same module as the type itself. In Set Theory the equivalent of an algebraic data type is a Discriminated Union – a set whose elements consist of a tag (equivalent to a constructor) and an object of a type corresponding to the tag (equivalent to the constructor arguments). AN EXAMPLE For example, in Haskell we can define a new algebraic data type, Tree: data Tree = Empty | ||
|   | Data List A | Nil Cons a (List a) |
|
|