A or B
a | b
(A or B) and (C or D)
a | b, c | d
Bool
is a set of 2 values.Char
is a set of 256 values.
data MySumType = Foo Bool | Bar Char
2 + 256
True | False | 'a' | 'b' | 'c' | ...
MySumType
is a set of 2 + 256 possible values.
data MyProductType = Baz (Bool, Char)
* 256 ––>
2 (True, 'a') | (True, 'b') | (True, 'c') | ...
(False, 'a') | (False, 'b') | (False, 'c') | ...
MyProductType
is a set of 2 * 256 possible values.
data MyProductType2 = Baz (Char, Char)
* 256 ––>
256 ('a', 'a') | ('a', 'b') | ('a', 'c') | ...
('b', 'a') | ('b', 'b') | ('b', 'c') | ...
| ('c', 'a') | ('c', 'b') | ('c', 'c') | ...
V ('d', 'a') | ('d', 'b') | ('d', 'c') | ...
('e', 'a') | ('e', 'b') | ('e', 'c') | ...
('f', 'a') | ('f', 'b') | ('f', 'c') | ...
('g', 'a') | ('g', 'b') | ('g', 'c') | ...
...
MyProductType2
is a set of 256 * 256 possible values.
data Person = Person {
isCool :: Bool
favChar :: Char,
}
* 256 ––>
2 Person {isCool = True, favChar = 'a'} | ...
Person {isCool = False, favChar = 'a'} | ...
Hopefully you get the idea.