Functions from Types to Types

In the last section, you learned how to work with a wide variety of type level data, including natural numbers, strings, and data structures like lists and tuples. Having all of this data available at the type level is of limited use without being able to write computations to transform the data. In Haskell, we can build type level functions using a feature called Type Families.

Type families are conceptually straightforward. A type family is a function that accepts some types and returns a type, just like a term level function accepts some term level values and returns a value. Unlike term level functions, there are different “varieties” of type family we’ll look at. Although each of these sorts of type family ...

Get Effective Haskell 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.