/ Cats/Scala

Learning Functional Programming with Cats

Like most blogs, mine is not too well structured so I thought it would be useful to tie the various posts together

If you want to learn FP and Cats I suggest reading the posts in this order:

  1. Type classes for beginners - Cats makes extensive use of type classes. A good understanding of this concept is therefore a prerequisite. Don't be scared! the concept is quite simple
  2. What is a Functor? - The familiar map() function is encapsulated as a Functor in Cats.
  3. What is a Semigroup? - Used to combine data together. When used with a Functor we have a very basic map-reduce system
  4. What is a Monoid? - Not to be confused with a Monad, a Monoid is like a Semigroup but allows us to combine data types that may be empty (e.g. Lists)
  5. What is a Monad? - The familiar flatMap() function is encapsulated by a Monad. Monad's are more powerful than you may realise
  6. Monad transformers - If you find yourself writing _.map(_.map(...)) or nesting flatMap() calls a Monad transformer may help ...
  7. Monad error - An advanced Monad that wraps another Monad to provide error handling semantics
  8. Applicatives vs Monads - If you've ever called Future.sequence() you've used an Applicative but you may not realise it
  9. Validated & ValidatedNel - Sometimes we want to accumulate errors instead of failing fast (like Either does). Cats offers us a useful utility for this called Validated