In the previous chapter, we have seen that Reason provides tools and techniques that open possibilities for programming generically. One is parametric polymorphism using type variables. Another one is the functor, which can take one or several modules as parameters and return a module.
In this chapter, we are going to look at ways of extending types themselves to add behavior to them. One such technique available in Reason is called subtyping. The idea is to have a hierarchical relation of types, with specific types being subtypes of more generic types. For example, a cat could be a subtype of mammal, which itself is a subtype of vertebrate.
We can find a definition about the subtyping approach in the OCaml documentation:
Subtyping governs when an object with one type A can be used in an expression that expects an object of another type B. When...