Syntax

We should mention here that the requirement to use the implicit mechanism with a Rich Wrapper pattern is a requirement that's specific to Scala. Scala is a language that mixes object-oriented and purely functional styles. This is why certain functional programming features such as type classes are not a part of the language and are implemented in a more generic way instead. This means that in Scala, method injection and the type class pattern are not first-class citizens. They are not defined at the language level. Instead, they leverage a more general mechanism that is defined on the class level—the implicit mechanism. Hence, in order to seamlessly use type classes in a Scala project, you need to use this mechanism so that they take ...

Get Mastering Functional Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.