Table of Contents
IntroductionBrian introduces the course, and explains what the intended audience is.
Mathematical, Pure FunctionsBrian explores three small tests to determine if one is writing a function: the object needs to be total, have an input for every output, be deterministic, and have no observable side effects.
Pure Functions ChecklistBrian reviews the checklist of what makes a mathematical, pure function, and asks the audience to determine if the examples presented are pure functions or not.
Pure Functions AdvantagesBrian explains how the mathematics used in functions can be useful when programming. Pure functions are reliable, portable, reusable, testable, and composable.
Properties, Arguments & CurryingBrian explores the properties of a few calculation functions, and demonstrates how to write a curried function.
Currying Example & Argument OrderBrian gives the example of the filter function, curries it, explains the argument order, and imports the currying function from the Ramda library to be able to curry with more than two arguments.
Ramda Generalized CurryingBrian explains how to use the Ramba library while currying a function, and demonstrates how to write point free functions.
Partial Application vs CurryingBrian explains that partial application and curried functions are dual functions. Partial application only uses one of its arguments, a curried function uses one argument at a time. The two functions have the same effect, but are written differently.
Currying ExercisesThe students are instructed to code the solutions to various currying exercises.
Currying SolutionsBrian live codes the solution to the currying exercises.
CompositionBrian defines composition and gives examples of composed functions. A function is composed when it contains one function nested in the other, and returns a new function.
Creating Programs with Curry & ComposeBrian demonstrates how to build a simple program using currying and compose, and argues that this way of writing code leads to consistent state mutations, but not efficient programming because of the absence of a clean data pipeline.
Logging in CompositionBrian demonstrates how to use logging in function composition to debug code.
Compose PracticeBrian demonstrates how to use compose in various examples, and rewrites functions into pipelines, making code easier to read.
Refactoring with ComposeBrian demonstrates how refactoring with function composition can make code easier to understand.
Refactoring to Point Free StyleBrian demonstrates how to refactor functions using the point free style, explains that it allows parallelization and a better data processing workflow thanks to the high level declarative syntax.
Creating the Identity FunctorBrian explains that a functor is a container that holds an object that is mapped over, demonstrates how to dot chain a function into a linear control flow, and explains that a functor is an object that has a map method. A functor is useful in functional programming because it abstracts function application.
Refactoring to Dot ChainingBrian demonstrates how to use dot chaining with a functor and refactors the code written in the previous lesson.
Functor PracticesBrian demonstrates how to use composition and sub-composition to nest functions. Nested functions are useful to have a clear idea of the data flow.
Adding Chain for Nested FunctorsBrian demonstrates how to write a function that allows for chaining methods and argues that one could use promise.then instead, but in an effort to stay deterministic and mathematical, the use of chaining is better.
Either MonadBrian explains that the type Either is a functor and a monad, it has both a map, a chain method, and a fold method. The Either type respects function purity and is effectively an if else statement, but inverted.
fromNullableBrian explains that fromNullable is useful because it is a definitive null check for every function, and avoids repetition.
Refactoring Using the Either MonadBrian demonstrates through a server example how to use the Either monad to refactor code.
Flattening Either Monads with ChainBrian demonstrates how to flatten the Either monad using both the chain and map methods.
Adding Syntax vs Generalized SolutionsBrian recommends using the Either type instead of exploring specific syntax that only covers one unique way of using the type.
Either PracticesBrian goes over examples of using the Either type using the dot syntax, and explains that, when working with Either, it is not possible to flatten an array of another type.
Debugging with LoggingBrian demonstrates how to use logs to debug the code, and answers questions about the Writer monad, a monad that, along with values, returns an error message.
Task MonadBrian explains that the Task monad is the functional equivalent of promise. Similarly to promise, Task takes resolve and reject functions, but in reversed order. A Task monad only starts running once it reaches the fork method, and this way avoids race conditions.
Refactoring Node IO with TaskBrian explains that Node IO, although commonly used, does not bring in any asynchronicity, and demonstrates how to use Task instead which gives a clean control flow.
Task PracticesBrian goes over different Task monad examples and familiarizes the audience with the Task syntax, and characteristics.
Transforms & Monad PatternsBrian explores various transformations, such as type transformations, free monads, and monoids with both the either and task monad.
Inspecting the Weather APIBrian demonstrates how to fetch weather data from the weather API, and explains the next data parsing steps.
Separate Pure & Impure CodeBrian builds a task monad to fetch data from an API and refactors the code using the Task monad.
Creating a Weather ModuleBrian demonstrates how to use the Task monad when creating a weather module, and how to use the monad in different places within the same application.
Parsing Weather API Data into HTMLBrian uses HTML to show some of the results gathered through the weather API on the screen, live codes a weather data type, and refactors the code into new types, making the application cleaner, and the functions within it more accessible.