# Derived Instances

The `deriving` keyword can be used to make a new type into an instance of other built-in classes `Eq`, `Ord`, `Show`, `Read`, and `Enum` without the need for defining any of the methods. For example, the `Bool` type can be declared as:

```haskell
data Bool = False | True
  deriving (Eq, Ord, Show, Read)
```

It is as if we are stating that the new data type `Bool` can have two values (two nullary constructors `True` and `False`) and it should also be made an instance of the classes `Eq`, `Ord`, `Show` and `Read`, but we let the compiler write the actual code for us using the default definitions. Note that for the `Ord` class, the default ordering will be the order in which the constructors are defined – in this case, `True` comes after `False` and is, therefore *"greater than"* `False`. With this definition, we can use methods of all the class instances included with the type `Bool`:

```haskell
ghci> True == True
True

ghci> False < True
True

ghci> show True
"True"

ghci> read "False"
False
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://haskell.hpmeducation.com/type-classes/derived-instances.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
