O'Reilly logo

Haskell Cookbook by Yogesh Sajanikar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required