What you'll learn:
- Create own typeclasses
- Write and use lawful instances of well-known typeclasses such as Functors, Applicatives, Monads, etc.
- Perform common programming tasks (validation, dependency injection, state management, etc.) in a functional way.
When we start our journey as a Scala developer, our first impression of the language may be that of 'a better Java'. We learn about classes, traits, pattern matching and some other constructs that make our life easier. At some point we come across the amazinghigher-order methods such as map, filter and fold. These serve as a great first taste of functional programming.
But what if I told you that there is much more than that?In this course I will show you how standard functional programming practices can help you write code that is more generic, robust and testable.
This course is divided into 3 main sections.
In the first section, we will learn about typeclasses. We will use as a driving example the problem of encoding and decoding objects into and from bytes. By the end of this section you will be able to create your own typeclasses and use the typeclass pattern to write polymorphic code.
In the second section, we will take a look at some of the most common typeclasses in functional programming, including Monads, Applicatives, Functors and many more. We will use the famous Cats library to provide us with their implementations, and we will use Discipline along with ScalaCheck and ScalaTest to test their laws. By the end of this section, you will be able to write lawful instances of these typeclasses for any of your types, and test their validity in an automated manner.
In the third and final section, we will learn to perform many common programming tasks with functional structures. These tasks include:
- Validations via the Validated datatype
- Dependency injection with the Reader monad
- Tracking data in our computations with the Writer monad
- Managing state with the State monad
- Writing stack safe computations with Trampolines
- Making computations lazy with the Eval monad
- Composing monad stacks via monad transformers such as ReaderT and OptionT
- Suspending effects with a simple but useful implementation of the IOmonad
I'm a big believer of learning by doing so I've included a lot of in-video exercises, along with quizzes and assignments at the end of each section. I hope you enjoy doing them as much as Ienjoyed putting them together!
Without further ado, Iwant to give you a big welcome to the course and the thrilling world of functional programming!