liveBook · Manning

Product type

A product type is a composite type whose values contain one value from each of several component types, representing combinations from their possible values.

How 3 Manning books explain it

Data-Oriented Programming in Java

A product type is a type whose values combine one value from each of several component types, corresponding to logical AND and a Cartesian product.

How it is used
Models records whose attributes must coexist and exposes the states their combinations permit.
How deep it goes
Defines products through Cartesian products, then previews symbolic laws and exhaustive state generation.
Examples
Uses a Beverage record and exhaustive RawData state generation with optional fields.
What you can do after
Evaluate/understand a record’s state space and use it for exhaustive invariant assertions.

Read how Data-Oriented Programming in Java explains product type →

Functional Design and Architecture: Examples in Haskell

A product type combines multiple component values into one composite value, such as a tuple or record.

How it is used
Uses product types to construct functional domain models and composite data structures.
How deep it goes
Defines tuples and records as product types and places them within algebraic data types, without detailing implementation semantics.
Examples
Demonstrates product types through PersonName tuples and Person records containing names and ages.
What you can do after
Build it from scratch by combining related values into tuple- or record-shaped domain types.

Read how Functional Design and Architecture: Examples in Haskell explains product type →

Write Powerful Rust Macros

A product type is a composite type whose possible values are combinations of values from all its component fields.

How it is used
Frames struct-like values as algebraic data types while motivating controlled alternatives for error handling.
How deep it goes
Defines state multiplication with a worked example, then contrasts product types with sum types without implementing product types.
Examples
Uses a struct containing a u8 and boolean, contrasting values such as 120,true and 119,true.
What you can do after
Evaluate how a struct’s field combinations expand its state space and why validation may require conditionals.

Read how Write Powerful Rust Macros explains product type →

Also covered in

What to know first

Related concepts

Questions about product type

What is product type?

A product type is a composite type whose values contain one value from each of several component types, representing combinations from their possible values.

Which Manning books explain product type?

Data-Oriented Programming in Java, Functional Design and Architecture: Examples in Haskell and Write Powerful Rust Macros.

What should I know before learning product type?

Manning books that teach product type usually introduce option, set and tuple first.

What is the difference between product type and union type?

A product type is a composite type whose values contain one value from each of several component types, representing combinations from their possible values. A union type is a type whose values can represent one of several specified alternative types or variants.

What kinds of product type are there?

Kinds of product type include record and anonymous record.

What is product type a kind of?

Product type is a kind of algebraic data type. An algebraic data type is a composite type whose values are formed from product structures, finite alternatives, or both through type constructors.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.