def. Algebraic Type System uses both:
- Product Types:
stuct Icon: {shape: Shape, x_pos: Int, y_pos: Int} - Sum Types:
enum Shape: Square | Circle | TriangleIntuition. It’s called algebraic because:
Thus looking at its cardinalities:
Search
def. Algebraic Type System uses both:
stuct Icon: {shape: Shape, x_pos: Int, y_pos: Int}enum Shape: Square | Circle | Triangle
Intuition. It’s called algebraic because:Thus looking at its cardinalities:
∣Icon∣=∣Shape∣⋅∣Int∣⋅∣Int∣=(∣Square∣+∣Circle∣+∣Triangle∣)⋅∣Int∣⋅∣Int∣=3⋅∣N∣⋅∣N∣