May 14, 2017

Functional Programming and Category Theory

Here you are.

For a long time you had the feeling that something wasn't quite right.
During your functional programming journey you started hearing things like monads, functor, applicative, group, semigroup.
Maybe even kleisli or natural transformations.
Scary terms, I know. It's late at night.
Then you suddenly wake up in your room and remember that not long ago someone told you about category theory.
Maybe that's the answer you are looking for...

Knock Knock Neo..

What is Category Theory

As Philip Wadler said:

"Category theory is easy stuff that I understand very well, made difficult."

Here I'm going to point you to some resources that I found very helpful helping me to learn Category Theory.

Category Theory for the Working Hacker by Philip Wadler

My favourite is the series Category Theory For Programmers 1 and Category Theory For Programmers 2 by Bartosz Milewski.
He is very good at teaching and in his lectures you can find very helpful practical examples.
If you are strongly interested in Category Theory, watching these lectures will be time well spent.

If you prefer reading, he also has a blog.
There is also this blog post by Heiko Seeberger.

Don't miss this awesome visual explanation of Functors Monads and Applicatives.

For more practical examples in Scala take a look at the Cats library.
The documentation is very well written, and Eugene Yokota wrote this nice blog post series.

After you have a general idea of what category theory is, you can dive into type classes with typeclassopedia, this blog post and this one.

I hope that those resources will help you to connect the dots between all of these concepts.

Keep Learning.
Until next time emoji-sunglasses