Product Type とは?
product type は、複数の構成要素の型を 1 つに結合し、struct やタプルのように、単一の値が各構成要素の値を同時に保持します。取りうる値の数は構成要素の可能性の積であり、これが型名の由来です。いくつかの選択肢のうち 1 つだけを保持する sum type と対照的です。
なぜ重要か
product type は、関連するフィールドを 1 つのまとまった値に束ねる日常的な手段です。product と sum を合わせて理解すると、豊かなデータモデルが単純な部品からどう構築されるかが明確になります。
関連ガイド
What Is a Sum Type?A sum type holds a value that is exactly one of several named alternatives, each potentially carrying differe…
What Is an Algebraic Data Type?An algebraic data type composes types as combinations of fields and alternatives, modeling data as products a…
What Is Pattern Matching?Pattern matching inspects a value against a set of shapes, selecting a branch and binding parts of the value…