Share on Facebook Share on Twitter Email
Answers.com

Product type

 
Wikipedia: Product type

In programming languages and type theory, the product of two types is the type that characterizes the expressions which behaves, with respect to the evaluation mechanism, as pairs whose first component is an expression of the first type and whose second component is an expression of the second type. It is written A × B, where A and B are its component types. Elements of a product type are called tuples.

In many languages, product types take the form of a record type for which the components of a tuple can be accessed by label. In languages that have algebraic data types, as in most functional programming languages, algebraic data types with one constructor are isomorphic to a product type.

In the Curry-Howard correspondence, product types are associated with logical conjunction (AND) in logic.

The notion directly extends to the product of an arbitrary finite number of types (a n-ary product type), and in this case, it characterizes the expressions which behave as tuples of expressions of the corresponding types. A degenerated form of product type is the unit type: it is the product of no types.

In call-by-value programming languages, a product type can be interpreted as a set of pairs whose first component is a value in the first type and whose second component is a value in the second type. In short, it is a cartesian product and it corresponds to a product in the category of types.

Most functional programming languages have a primitive notion of product type. For instance, the product of type1, ..., typen is written type1 * ... * typen in ML and (type1,...,typen) in Haskell. In both these languages, tuples are written (v1,...,vn) and the components of a tuple are extracted by pattern-matching. Additionally, many functional programming languages provide more general algebraic data types, which extend both product and sum types.


Search unanswered questions...
Enter a question here...
Search: All sources Community Q&A Reference topics
 
 
Learn More
Generonym (Definition)
Attribute (business term)
Fusion (technology)

What type of economy products do italy have? Read answer...
What type of products are made in Taiwan? Read answer...
What type of products are made from Batik? Read answer...

Help us answer these
What are the types of production?
What type of product is TSP?
Give types of crop production?

Post a question - any question - to the WikiAnswers community:

 

Copyrights:

Wikipedia. This article is licensed under the Creative Commons Attribution/Share-Alike License. It uses material from the Wikipedia article "Product type" Read more