A lot of times when we write software, we encounter similarities between different implementations. An important principle of good code design is to avoid repetition and it is known as do not repeat yourself (DRY). There are multiple ways that help us to avoid repetitions—inheritance, generics, and so on.
One way to make sure we do not repeat ourselves is through type classes.
A concrete example would be Numeric. We can say that it is a type class and defines the operations—addition, subtraction, multiplication, and so on, for the Int, Double, and such other ...