In Scala, Rich Wrapper is a pattern that allows you to simulate method injection into classes.
The pattern is implemented in Scala using the implicit conversions mechanism. Whenever you are trying to call a method on a class that doesn't have this method, the compiler tries to convert the instance of that class into another class that has this method.
See the explanation in the Intuition section in Chapter 7.
The motivation behind the type class pattern is to separate the effect types from their behaviour so that it is possible to define new behaviours and inject them into existing type classes based on different scenarios that arise when performing functional programming.
Yes, imperative languages do have type classes. However, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.