The preceding example is rather simple, but it cleverly uses the type family. Look at the definition of VectorSpace type-class. We know that we can scale a vector by a scalar. The type class VectorSpace allows us to define our data structure as a vector. however, we should also be able to customize which scalar we would like to associate with this type.
The VectorSpace type class is defined as follows:
class AdditiveGroup v => VectorSpace v where type Scalar v :: *
In the preceding class definition, the type Scalar is defined as type Scalar v :: *. The type Scalar v means that, for a data type v, which is an instance of VectorSpace, there is a scalar associated with it. And this type Scalar can be defined as we define the ...