Chapter 10

Dealing with Types


Check Understanding types

Check Creating and managing types

Check Fixing type errors

Check 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 ...

Get Functional Programming For Dummies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.