Jump to ratings and reviews
Rate this book

The Type Astronaut's Guide to Shapeless

Rate this book
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 (https://github.com/underscoreio/shape...).

111 pages, Paperback

Published December 1, 2016

2 people are currently reading
39 people want to read

About the author

Dave Gurnell

6 books5 followers

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
31 (46%)
4 stars
30 (44%)
3 stars
5 (7%)
2 stars
1 (1%)
1 star
0 (0%)
Displaying 1 - 8 of 8 reviews
Profile Image for Daniel.
Author 3 books37 followers
February 4, 2017
This is not a comprehensive manual for the Shapeless library. Rather, it is a really well-written guide that explains some of the library's most important features and core design principles, equipping the reader with the prerequisites to dig into other features on their own.

Even though the book is about Shapeless, it is also a worthwhile read if you want to deepen your knowledge about type classes and path dependent types in Scala in general.

The selected Shapeless features are explained by means of some use cases, of which I find only one really compelling: boilerplate-free generation of test data. The other use cases are about automatic derivation of CSV and JSON serialisation type classes. While they are great for explaining how Shapeless works and seem to be tremendously popular use cases in the Scala community, I don't find them very convincing – in any real world project, where it is important to be able to refactor your domain model without breaking your JSON API, you probably want to write the JSON serialisers manually instead of deriving them automatically.
Profile Image for Lori.
348 reviews67 followers
April 9, 2018
This book contains everything you need to know to get your feet wet with shapeless. It does not cover the entire library, but it is definitely a great help in trying to understand what it is about, give you an intuition about the kinds of problems that shapeless can be, and ought to be used for. But, most importantly it helps you understand why using type-class derivation the shapeless way can blow up compile times exponentially, at the same time giving you the knowledge and tools to fix the problem.
Profile Image for Miguel.
106 reviews6 followers
September 11, 2017
A natural progression when working with scala and case classes(Abstract data types).

Gives you an overview on how to use the shapeless library and mostly focuses on theory and the "big picture". Once the concepts stick, you'll understand how the library is meant to be used and where it is a good tool and where it is not. The Lemma Pattern(Aux method) is especially interesting and applying it will make using shapeless a breeze.
Profile Image for Clay.
37 reviews5 followers
April 1, 2018
Was unpleasantly surprised by this one given the ratings; I typed out and played with the code from every chapter (half of it doesn't compile) except for the last one, because its applications were such an incredible stretch. It's rather tedious, doesn't properly motivate the reader (you can do all the stuff from this book that you actually want to do with vanilla Scala), doesn't come with exercises, generally repeats the same pattern over and over again (implicits to convert primitives, method to convert HList intepretation into LabelledGeneric values, and a converter to take your ADT to an HList).

I work in a modern scala codebase 40+ hours a week with over sixty thousand lines of code and couldn't think of a single place where this stuff would be applicable. I think shapeless can be useful for building libraries (spray json was an example in the book that I've used in production), but not for day-to-day programming tasks. The only thing I got from this book that might be useful is the idea of (an idea I got from a talk an North East Scala Conference 2018 and not this book, mind you) tagging instances of case classes with phantom types to indicate the status of the data or provide metadata (eg: valid, invalid, etc), but this can just be accomplished with type aliases! I'm moving onto Scala with Cats after this (also by underscore) and perhaps that will shed some light on the importance of Shapeless, but until then I'm not going to recommend this book unless you're knee deep in polymorphic mapping.
223 reviews12 followers
March 19, 2017
A quick 100 page read makes an obscure topic (shapeless) terrifically transparent. I feel like I am ready to use shapeless now.
205 reviews17 followers
November 12, 2017
An excellent, practical introduction to what you can do with Shapeless. If your Scala project has reached the stage when Shapeless is desirable (and most of them unfortunately do), this is your best guide on what it is about and how to use it.

Now your biggest worry will be to avoid the urge of rewriting everything in Haskell...
2 reviews
February 13, 2019
Excellent but wish I had my computer with me when I read it so I could try some examples.
Displaying 1 - 8 of 8 reviews

Can't find what you're looking for?

Get help and learn more about the design.