Overview

The Type Astronaut’s Guide is aimed at experienced Scala hitch hikers with an interest in generic programming and boilerplate elimination. The book walks you through one of the main use cases for shapeless – automatic, boilerplate-free derivation of type class instances.

The book is divided into two parts. Part I introduces the general mechanisms for type class derivation in shapeless. It introduces generic encodings of product and coproduct types (case classes and sealed traits), and shows how to implement type classes by solving problems at the generic level.

In Part II we open the shapeless toolbox and show how to apply the solutions from Part I to a wider range of situations. We introduce polymorphic functions that let us map and flatMap over generic representations, and show how we can count at the type level.

Each chapter of the book is illustrated with worked examples that are also available on Github.