Introduction to Type Classes
Get introduced to the concept of type classes.
We'll cover the following...
In the previous lesson, we defined our own data type for geometric shapes. In order to make them printable, we had to add deriving (Show)
to our type declaration.
Show
is an example of a Haskell type class. We also encountered the type class Eq
, already, in type annotations of polymorphic functions (e.g. elem
), where it acted as a constraint. In this lesson, we will learn in more detail what type classes are and how we can use ...