Table of Contents
IntroductionBrian introduces the course by explaining that architecture is about grouping things, and gives a refresher on the main functional programming properties.
Naming & GroupingBrian introduces the identity functor, and explains that it takes a value and returns a value. The identity functor is founded on category theory, which states that functional programming necessitates both composition and identity.
Composition ArchitectureBrian compares working with one big function that does all the work with little functions that represent small functionalities from a given application, and says that this course will focus on composition involving multiple small functions.
Normalize Effect TypesBrian explains that normalizing the effect types within the app is a good guiding principle to allow every element within the app to compose, and says that different ways to solve this issue will be reviewed in the next sections.
Semigroups & Monoids
What is a SemigroupBrian explains that a semigroup is a structure that contains an associative operation, and that is closed. Explanation is given for why a closed and associative.
Creating Semigroup Data TypesBrian explains how to lift an operation through a type to be able to program an interface.
Defining Empty IdentityBrian explains that monoids are semigroups with an identity, and live codes examples of monoids.
foldMapBrian explains that foldMap takes elements, maps them into a certain type, and then folds them.
Semigroup vs MonoidBrian explains the main differences between a monoid and a semigroup. A semigroup can have an empty identity.
Identity FunctorBrian explains that functors are monoids, and demonstrates the advantages of programming to an interface. Programming to an interface means referring to a more abstract level than a class.
Concat MethodBrian demonstrates how to concat different functors together, and how to use the concat method to join different monoids.
Monoid ExercisesThe students are instructed to code different monoid exercises.
Monoid SolutionsBrian live codes the solutions to the monoid exercises.
Monoid Use CasesBrian shares two use cases for monoids to demonstrates how monoids can be used in everyday code and make code cleaner.
Homomorphisms & MonadsBrian gives an example of a homomorphism. A homomorphism takes two elements and combines them then goes through a type transformation. At a high level, when combining a monoid operation and flattening two types, these types become monads.
Creating a Validation LibraryBrian demonstrates how to architect an app around validation, and builds a validation library that combines different kinds of validations, and provides errors or a final object.
Creating Success & Fail MonoidsBrian demonstrates how to create success and failure types, and adds a concat method, therefore building two monoids.
Creating the Validation MonoidBrian continues to develop the validation library, and demonstrates how to create a validation monoid.
Function ModelingBrian explains that, instead of modeling data, it is possible to model a function. Functional modelling allows to use different methods.
The Reader MonadBrian demonstrates how to use the Reader monad to add dependency connections and thread invisible environments through an entire program.
The Endo FunctorBrian explain that the endofunctor is called endo because it only works with the same kind of types.
contramapBrian explains that contramap maps over inputs, combines two reducers that were previously contermapped demonstrating that contermap hits arguments before it comes in.
Function Modeling PracticesBrian live codes function modeling and demonstrates how to use Endofunction, predicate, and how to use the contramap or contravariant functor. An endofunction is a function that has an equal domain and codomain.
Function Modeling EquivalencesBrian demonstrates how to combine reducer functions, and transform them into an Endo type, and explains that the two are equivalent.
Composing FunctorsBrian explores different types of functors using the map, extract and fork methods, and explains that functors have different identities, can be composed together, and have a category within which they act like functions.
Monad TransformersBrian explores the use of monad transformers with the Task transformer which contains a lift method that will avoid duplicating an inner type. A transformer is a monad that merges two monads together. Transformers are needed because unlike functors, monads do not compose.
Reconstructing with Monad TransformersBrian introduces monad transformer based libraries, and explains that each transformer is useful for a specific task, and reconstructing code with monad transformers requires understanding which transformer to use at the right place.
Monad Transformers PracticesBrian covers monad transformer practices, and demonstrates how to use the lift method.
Defining the Free MonadBrian explains that the free monad is a way to treat functions like datatypes, and gives an example of a free monad that takes a url as an argument, returns a datatype, and the content of the argument, in this example, the url.
LensesBrian explains that lenses are built on functors and, compose backwards going left to right, adds that it is possible to write an entire application with lenses, and demonstrates how to treat properties as functors.
Monadic Web Apps
Building a CLI AppBrian explores how to build a CLI blog for creating and viewing blogposts by focusing on the architectural decisions to build the app in a functional way.
Refactoring Recursive TasksBrian continues building the CLI blog and uses different forms of function modeling to refactor code, such as the fix type.
Free MonadsBrian continues to refactor the CLI blog app using Free monads to test the different app tasks.
InterpretersBrian adds interpreters to the different free monads. Interpreters allow developers to log information about how the Free monad runs.
Creating an Alternative ReduxBrian explores a new application and starts building an alternative Redux that is contained in the event loop. Redux is a bare-bones approach to functional UI. The alternative takes advantage of monads, function modeling, monoids, and lenses.
Using the ask Method & LensesBrian continues to build the application started in the previous section so that state is merged automatically when the ask method runs, uses lenses to alter state in an elegant and immutable way, and builds reducers that compose and are unary functions.