O'Reilly logo

Get Programming with Haskell by Will Kurt

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

Lesson 14. Using type classes

After reading lesson 14, you’ll be able to

  • Implement your own type classes
  • Understand polymorphism in Haskell
  • Know when to use deriving
  • Search for documentation with Hackage and Hoogle

In lesson 13, you got your first look at type classes, which are Haskell’s way of grouping types by common behaviors they share. In this lesson, you’ll take a deeper look at how to implement existing type classes. This will allow you to write new types that take advantage of a wide range of existing functions.

Consider this

You have a data type consisting of data constructors for New England states:

data NewEngland = ME | VT | NH | MA | RI | CT

You want to be able to display them by their full name by using Show. You ...

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