Definition
A record type (also called a struct in some languages) is a Product Type where each field is named rather than accessed by position. A record with fields and corresponding types has type:
Type-Theoretic Perspective
Record types have:
- Introduction rule: Given values , we can form
- Elimination rules: Field projection extracts the value of field from record
Unlike ordered tuples, records are accessed by field name rather than position, making them more robust to reordering.
Examples
In various type systems:
- A point record:
- A person record:
Properties
- Field access is by name: extracts field
- Field order in the type is typically irrelevant for equality
- Records can be nested: fields may themselves be records
- Some type systems support row polymorphism for extensible records
Related Concepts
- Product Type: The underlying type-theoretic structure
- Ordered Tuple: Records without named fields
- Dependent Pair: Generalization where types may depend on values
- Sum Type: The dual to record types