In this talk, we'll define exactly what functional programming is and how it helps us. We'll explore the main concepts from functional programming and see how we can apply them to our Python code going over some concrete examples.
We'll look at how we can prove if a function is pure or not, and what the implications are of writing our code more explicitly. We'll look at an existing snippet of code that uses mutation and how we can transform such a function into one that is referentially transparent.
We'll go over a concrete example of using branching logic and nested if
s to check for emptiness. Again, we'll transform this code by using the Option monad and make our code more readable and robust.
We'll take a look at dealing with exceptions using the try..except
syntax. We'll change this to using the Try monad and see how our code reads from left-to-right and how we can make the side-effects of our functions more explicit to the caller.
We'll take an example which uses threads and processes and change it into an example that uses the Future monad. Along the way, we'll see how we can more explicitly handle asynchronous behaviors and their effects.
We'll conclude by looking at the pros and cons of functional programming and where we can use it in our Python code.