Data Types Questions and Answers¶
types aka¶
Types are also known as…
datatypes.
enumerate types¶
List three datatypes that come with Prelude.
CharWordDouble
values and types¶
Values have types. In Haskell, we cannot have an untyped value. Types are like groups that contains values that belong to that group.
Enumerate a few values that would belong to the type (a.k.a datatype)
Char and a few that would belong to the type Word.
Char:'a''9'' '
Word042
It is important to note that Word includes only natural numbers,
from zero onward.
data declarations¶
What do data declarations do?
Data declarations define types (a.k.a. data types).
basic data declaration¶
λ> :info Bool
data Bool = False | True
Identify type constructors and data constructors above.
Bool is the type constructor. False and True are the two
possible data constructors that belong to the type or datatype
Bool.
Note
Although we say data declaration, we are not defining __only__ data constructors. We are in fact defining both type constructors and data constructors.