Getting Started with Types
Although a formal definition of types is outside of the scope of this book, informally you can think of a type as a way of identifying some collection of different values. For example, the Bool type is a way of naming the set of values True and False ; similarly, the Integer type is a way of naming the set of all the whole numbers. To be precise, you can say the values True and False inhabit the type Bool , or they are its inhabitants , although informally throughout this book we’ll simply say “ True is a Bool .”
Every value has a type, whether it’s a number, some text, or a function. The way the value was created doesn’t matter; a literal value of True defined at the top level of the program, returned by a function, or bound in a let expression will still have the type of Bool . Since there are many ways of creating a value with some type, it’s common to say that, for example, an “expression has type Bool .”
Later in this chapter, you’ll learn about some of the commonly used types defined in the standard library, and after that you’ll learn how to associate a value with a type.