Learn Scala Programming
上QQ阅读APP看书,第一时间看更新

Getting to Know Implicits and Type Classes

We are already familiar with two cornerstones of Scala—its type system and first-class functions. Implicits is the third one. Implicits enable elegant designs and probably no state-of-the-art Scala library is possible without them.

In this chapter, we will start with a systematic overview of different types of implicits and recap the implicit scope resolution rules. After taking a short look at context bounds, we'll move on to type classes, the central implementation mechanism that's utilized in modern functional programming libraries.

The following topics will be covered in this chapter:

  • Types of implicits
  • Context bounds
  • Type classes
  • Type classes and recursive resolution
  • Type class variance
  • Implicit scope resolution rules