Awesome
Typeclassopedia
This project aims to be a simple implementation of the Typeclassopedia in Scala. (If you find a simpler way to express something then please report it or send a pull request.)
Some people learn better by seeing things in code, with examples, which is why I started doing this. The tests are intended to be examples using typical types like Option and List, but also a custom type, Blub, to show that new types can make use of the type classes defined here.
Read The Road to the Typeclassopedia which I hope will be a gentle introduction to the ideas from examples rather than from theory.
How to Start
I suggest you start with Functor as it is the simplest class to study, then Applicative, Monad, Semigroup and Monoid. Then have a look at Validation which is not part of the Typeclassopedia but it's useful.
But before you do any of that, you need to understand type classes in scala.
The tests serve as examples of use.
Exercises
There is only one exercise.
- Check out the project
- Delete src/main/scala/org/typeclassopedia/std
- Delete src/test/scala/org/typeclassopedia/Blub.scala (except for the case class itself)
- Make all the tests pass again
Further Reading
- This project contains a copy of The Monad.Reader Issue 13 containing Brent Yorgey's The Typeclassopedia which provides descriptions of all the types defined here.
- Type Basics
- Advanced Types - particularly the section on Higher-kinded types & ad-hoc polymorphism
- Functors, Monads, Applicatives – can be so simple by Dirk Detering
- The Essence of the Iterator Pattern by Eric Torrebore
- Haskell Typeclassopedia
- Typeclassopedia presentation (use arrow keys)
- Learning Scalaz by Eugene Yokota
- Applicative Programming with Effects McBride and Paterson’s classic paper
- Introduction to Category Theory in Scala by Heiko Seeberger
Books
Talks
- Scala Typeclasses presented by Dan Rosen
- Scala Typeclassopedia presented by John Kodumal