Unit 4 - Composite Values: Records and Tuples Flashcards
Types of composite values
- Record Types
- Union Types
- Collections (arrays, lists, maps)
- Recursive types (trees, graphs)
Composite values are made up of
clearly identifiable components, each of which can be either primitive or composite.
A composite type describes a
family of composite values, all of which typically have a similar structure.
Records are
mappings from component names to components
A Java object viewed only as a collection of its attributes
is an example of a record.
Tuples are like records except that
their components have no names.
Values cannot be modified in Haskell
only constructed
Ada, Haskell provide pure records and unions with
good compile-time type-checking
C is flexible but very
little type-checking harms safety
Haskell supports the extraction of multiple components from records and unions using
pattern matching