liveBook · Manning

Product type

A product type is a composite type whose values combine one value from each of several component types, such as a tuple or record.

How 2 Manning books explain it

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 →

Related concepts

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.