Now that we have familiarized ourselves with Monoid and had a look at how it is used in the context of simple types such as integer, let's take a look at our previous example, the example of Either with a generic type of Left—Either[L, A]. How can we define the Applicative instance for a generic Left type? Previously, we saw that the body of the ap function for a generic Left type is not very different from the body of this function for the list. The only problem was that we didn't know how to combine two arbitrary types.
This combination sounds like exactly the task for Monoid. So, if we bring the implicit dependency on Monoid into scope, we can define the ap and Applicative type class for the Either type as follows: ...