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

How it works...

The item in a set needs to be ordered, and being ordered also forces a definition of equality. Hence, we have defined Eq and Ord instances for our data type. Depending on the situation, we might want to create the order differently. For example, if you would like, you can make the search based on the book title or author.

In a case where a different type class behavior is expected than the implementation, a typical trick is to wrap the existing data type, for which type class instance is already defined, in another type, and then define the type class instance for it instead.

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