Chapter 10
Dealing with Types
IN THIS CHAPTER
Understanding types
Creating and managing types
Fixing type errors
Using types in code
The term type takes on new meaning when working with functional languages. In other languages, when you speak of a type, you mean the label attached to a certain kind of data. This label tells the compiler how to interact with the data. The label is intimately involved with the value. In functional languages, type is more about mapping. You compose functions that express a mapping of or transformation between types of data. The function is a mathematical expression that defines the transformation using a representation of the math involved in the transformation. Just how a language supports this idea of mapping and transformation depends on how it treats underlying types. Because Haskell actually provides a purer approach with regard to type and the functional programming paradigm, this chapter focuses a little heavier on Haskell.
As with other languages, you can create new types as needed in functional languages. However, the manner in which you create ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access