Defining data with functions

So far, we looked at data types that take the values of other data types (both simple or complex). Since Haskell functions are also treated as first-class values, we can also use functions in our data type definition. In this recipe, we will define two data types that use functions as one of the field.

The first data type encapsulates a function f :: a -> b, whereas the second data type is an interesting recursive structure.