Copyright © Philip M. Parker, INSEAD. Terms of Use.

ALGEBRAIC DATA TYPE

Specialty Definition: ALGEBRAIC DATA TYPE

DomainDefinition

Computing

Algebraic data type (Or "sum of products type") In functional programming, new types can be defined, each of which has one or more constructors. Such a type is known as an algebraic data type. E.g. in Haskell we can define a new type, "Tree": data Tree = Empty | Leaf Int | Node Tree Tree with constructors "Empty", "Leaf" and "Node". The constructors can be used much like functions in that they can be (partially) applied to arguments of the appropriate type. For example, the Leaf constructor has the functional type Int -> Tree. A constructor application cannot be reduced (evaluated) like a function application though since it is already in normal form. Functions which operate on algebraic data types can be defined using pattern matching: depth :: Tree -> Int depth Empty = 0 depth (Leaf n) = 1 depth (Node l r) = 1 + max (depth l) (depth r) The most common algebraic data type is the list which has constructors Nil and Cons, written in Haskell using the special syntax "[]" for Nil and infix ":" for Cons. 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. Objects 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). (1994-11-23). Source: The Free On-line Dictionary of Computing.

Source: compiled by the editor from various references; see credits.

Top     

Specialty Definition: Algebraic data types

(From Wikipedia, the free Encyclopedia)

In functional programming, new types can be defined, each of which has one or more constructors. Such a type is known as an algebraic data type. For example, in Haskell we can define a new type, "Tree":
data Tree = Empty | Leaf Int | Node Tree Tree

with constructors "Empty", "Leaf" and "Node". The constructors can be used much like functions in that they can be (partially) applied to arguments of the appropriate type. For example, the Leaf constructor has the functional type Int -> Tree.

A constructor application cannot be reduced (evaluated) like a function application though since it is already in normal form. Functions which operate on algebraic data types can be defined using pattern matching:

depth :: Tree -> Int
depth Empty	 = 0
depth (Leaf n)	 = 1
depth (Node l r) = 1 + max (depth l) (depth r)

The most common algebraic data type is the list which has constructors Nil and Cons (Cons is the operator ++ or : defined to join two lists togheter), written in Haskell using the special syntax "[]" for Nil and infix ":" for Cons.

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. Objects 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).

This article was originally based on material from FOLDOC, used with permission. Update as needed.

Source: adapted by the editor from Wikipedia, the free encyclopedia under a copyleft GNU Free Documentation License (GFDL) from the article "Algebraic data types."

Top     

Crosswords: ALGEBRAIC DATA TYPE

Specialty definitions using "ALGEBRAIC DATA TYPE": constructed typediscriminated unionsum of products type. (references)

Top     

Alternative Orthography: ALGEBRAIC DATA TYPE


Hexadecimal (or equivalents, 770AD-1900s) (references)

41 4C 47 45 42 52 41 49 43      44 41 54 41      54 59 50 45

Leonardo da Vinci (1452-1519; backwards) (references)

        

Binary Code (1918-1938, probably earlier) (references)

01000001 01001100 01000111 01000101 01000010 01010010 01000001 01001001 01000011 00100000 01000100 01000001 01010100 01000001 00100000 01010100 01011001 01010000 01000101

HTML Code (1990) (references)

&#65 &#76 &#71 &#69 &#66 &#82 &#65 &#73 &#67 &#32 &#68 &#65 &#84 &#65 &#32 &#84 &#89 &#80 &#69

ISO 10646 (1991-1993) (references)

0041 004C 0047 0045 0042 0052 0041 0049 0043      0044 0041 0054 0041      0054 0059 0050 0045

Encryption (beginner's substitution cypher): (references)

354641393652354337238355435254595039

Top     



INDEX

1. Crosswords
2. Orthography
3. Bibliography


  

Copyright © Philip M. Parker, INSEAD. Terms of Use.