This chapter features another useful and fun type class:
Monoid. This type class is for types whose values can be combined together with a binary operation. We’ll cover exactly what monoids are and what their laws state. Then we’ll take a look at some monoids in Haskell and how they can be of use.
First, let’s take a look at the
newtype keyword, because we’ll be using it a lot when we delve into the wonderful world of monoids.
So far, you’ve learned how to make your own algebraic data types by using the
data keyword. You’ve also seen how to give existing types synonyms with the
type keyword. In this section, we’ll look at how to make new types out of existing data types by using the