Functional Programming with Scala Cats

Functional Programming with Scala Cats

English | MP4 | AVC 1280×720 | AAC 44KHz 2ch | 95 lectures (10h 45m) | 3.12 GB

A journey into the world of typeclasses, the Cats library, and the functional way of doing things in Scala

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 amazing higher-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 IO monad

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 I enjoyed putting them together!

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.
Table of Contents

Introduction
1 Introduction
2 Project Setup

Typeclasses
4 Introduction
5 Channel – Any
6 Channel – Any – Code
7 Channel – Inheritance
8 Channel – Inheritance – Code
9 Channel – Typeclasses
10 Channel – Typeclasses – Code
11 Channel – Typeclasses – Advantages
12 Implicits and Helper Methods
13 Implicits and Helper Methods – Code – Organizing instances
14 Implicits and Helper Methods – Code – Organizing instances #2
15 Implicits and Helper Methods – Code – Summoner method
16 Implicits and Helper Methods – Code – Instance method
17 Channel – Read
18 Channel – Read – Code
19 Laws
20 Laws – Code
21 Automatic instance derivation
22 Syntax
23 Syntax – Code
24 Summary
25 Assignment Creating our own typeclass

Well known typeclasses
26 Introduction
27 Eq
28 Eq – Code
29 Order
30 Order – Code
31 Show
32 Show – Code
33 Monoid
34 Monoid – Code – Speed
35 Monoid – Code – Exercises
36 Higher Kinded Types
37 Functor
38 Functor – Code
39 Applicative
40 Applicative – Code – Validated
41 Applicative – Code – Option
42 Monad
43 Monad – Code – Option
44 Monad – Code – List
45 Monad – Code – Either
46 Monad – Code – Try
47 Monad Error
48 Monad Error – Code – Instances
49 Monad Error – Code – Example
50 Monad Error – Code – Additional Functions
51 Foldable – FoldRight
52 Foldable – FoldLeft
53 Foldable – Typeclass
54 Foldable – Code – MList
55 Foldable – Code – Find
56 Foldable – Code – Exists
57 Foldable – Code – To List
58 Foldable – Code – For All
59 Traverse
60 Traverse – Code – MList
61 Traverse – Code – Option
62 Testing – Box
63 Testing – Instances
64 Testing – Properties
65 Summary
66 Assignment The Get Monad

Functional Techniques
67 Introduction
68 Validations
69 Validations – Code
70 Dependency Injection
71 Dependency Injection – Code – The Reader Monad
72 Dependency Injection – Code – Modularization
73 Dependency Injection – Code – Exercise
74 Tracking
75 Tracking – Code – The Writer Monad
76 Tracking – Code – Discounts Example
77 Tracking – Code – Exercise
78 State Management
79 State Management – Code – The State Monad
80 State Management – Code – Tic Tac Toe Example
81 Trampolines
82 Trampolines – Code – IsEven
83 Trampolines – Code – FlatMap
84 Evaluation Modes
85 Evaluation Modes – Code – The Eval Monad
86 Evaluation Modes – Code – Stream Example
87 TailRecM
88 Monad Transformers
89 Monad Transformers – Code – ReaderT
90 Monad Transformers – Code – OptionT
91 Suspending Side Effects
92 Suspending Side Effects – Code – IO
93 Suspending Side Effects – Code – Monad
94 Summary
95 Final Project

Homepage