klequis / zz-haskell-notebook

Notes from learning Haskell
1 stars 0 forks source link

Data declarations #10

Open klequis opened 2 years ago

klequis commented 2 years ago

Data declarations are how datatypes are defined.

Here is the data declaration for Bool which states that Bool can be True or False

--               [C]
data Bool = False | True
--   [A]     [B]      [D]

A. The type constructor for Bool, which is the datatype's name. B. Data constructor for the value False C. | (pipe) indicates "or". It is a sum type or logical disjunction D. Data constructor for the value True