August 2018
Intermediate to advanced
380 pages
10h 2m
English
Type classes are defined in terms of the methods they support. When defining a type class, you do not have an idea of how exactly the methods will be implemented for every given data type. However, you do have a rough idea of what these methods will do. For example, we have a rough idea that flatMap is responsible for sequential composition, and pure corresponds to lifting a value into an effect type without doing anything else.
This kind of information regarding how the methods should behave can be encapsulated in terms of the mathematical laws that the type class must obey. In fact, the majority of type classes can be viewed from a mathematical perspective, and so there are certain laws that they must obey.
Let's take a look at the ...