@@ -68,7 +68,7 @@ typeclass `Eq`, meaning that `a` must be a type for which the function `(==)` is

defined. A basic definition of the typeclass `Eq` could be

```haskell

classBasicEqawhere

classEqawhere

(==)::a->a->Bool

```

...

...

@@ -116,8 +116,18 @@ instance Eq a => Eq (Maybe a) where

(==)NothingNothing=True

(==)__=False

```

Note that we have atypeclass constraint on `a` being in `Eq`, since otherwise we could not have `x == y` in the second line.

Note that we have atypeclass constraint on `a` being in `Eq`, since otherwise we could not have `x == y` in the second line.

## Automatic derivation

It turns out that GHC can automatically derive instances for certain typeclasses. Instead of manually writing `instance Eq Color` above, we can just write

```haskell

dataColor=Red|Green|Blue

deriving(Read,Show,Eq,Ord)

```

On the type `Color`, this will automatically implement functions for string parsing (`Read`), string printing (`Show`), equality testing (`Eq`), and ordering (`Ord`).