Foundations of Professional Scala

Contents

It’s best to take the chapters in order, because each one builds on the code from the one before.

Start reading Also as ePub, mobi and PDF, or one chapter at a time. Download the code for every chapter.
  1. Preface

Part I: Scala for Java developers

These chapters stay close to Java and cover values, case classes, collections, Option and testing.

  1. 1. Up and running

  2. 2. Values, methods and expressions

  3. 3. Case classes, enums and traits

  4. 4. Collections

  5. 5. Option, and life without null

  6. 6. Testing with MUnit

Part II: Getting the compiler to do the work

This part adds functions as values, types that model the problem and errors as ordinary values, then generics and givens.

  1. 7. Functions as values

  2. 8. Modelling with types

  3. 9. Errors as values

  4. 10. Generics and variance

  5. 11. Givens and type classes

Part III: Effects

Programs that do input and output and run concurrently, written with Cats Effect and fs2. The last chapter does the same work in direct style.

  1. 12. Build your own IO

  2. 13. Cats Effect

  3. 14. Concurrency

  4. 15. Failure, retries and timeouts

  5. 16. Streams with fs2

  6. 17. Direct style

Part IV: A real service

The project gets an sbt build, an HTTP API, a Postgres database, more tests and a Docker image. The last chapter is about Play.

  1. 18. From scala-cli to sbt

  2. 19. An HTTP API with Tapir and http4s

  3. 20. Postgres with doobie

  4. 21. Testing the service

  5. 22. Shipping it

  6. 23. Play: the Scala you’ll inherit

Appendices

Short guides to Scala 2 code and to the libraries the book doesn’t use.

  1. Appendix A: Reading Scala 2

  2. Appendix B: The rest of the ecosystem