Completion of this course should be your next step after learning the basics of functional programming. In a few hours you’ll learn what many functional programming articles and tutorials fail to capture; how should one begin to connect all these FP concepts into an application?
You will learn how to create compositions of functional code, handle impurities and I/O, along with how to understand that funky syntax found in so many functional programming articles and documentation.
About the Author :
When we call other functions inside pure functions, the pure function becomes dependent on those other functions. Compose can create new functions by passing the results from applying one function into another function implicitly, decoupling this logic from inside the function bodies.
The compose we’ve used is dependent on taking a specific number of functions as input. We’ll often need to refactor compositions by adding or removing functions, so we’d be better with a compose utility that could create compositions that use any number of functions we happen to pass into it.
Composition creates functions without points, meaning no explicitly written parameters or returned values. This obfuscates the type of data a function expects from the programmer. A proven type system could help us document function types and give inference to their correctness when combined within compositions.
At the root of functional programming is well proven math. Composition isn’t a creation; it’s a discovery. The benefits of functional programming come from understanding that our programs are going to operate predictably, that they will run properly. These laws will help us to continue growing the complexity of our web app.
We’ve learned about pure functions and why they are so valuable in functional programming. Now, we’ll look at a type of pure function called a combinators. Combinators encapsulate common patterns, allowing us to perform much more complex and interesting operations inside compositions by combining logic.
Composition is great, but it makes it difficult to debug functions properly because we’re not explicitly writing functions for each composition. Console logging inside a function might cast too wide a net and using console.log directly would break the compositions output.
Composition is fairly linear; the input goes in one function and then out into the next. This makes it difficult to do meaningful operations in a point-free way because, eventually, values from multiple operations will need to be merged.
We don’t yet have any way to deal with unknown or unexpected values within a composition. Once a value is passed into a composition, it will be beneficial to be able to determine the next function to apply on the fly
Impure actions are not important to the pure functions that process their information. All that is important from impure actions are the end results. We’ll create containers that keep impurities in a box, run them in a box, and give us back only the results.
The generic container that we created has a special quality to it, we give it a function to hold and that code doesn’t run immediately. This behavior is like a lazy promise. We have control over when it runs, saving resources delaying work until it needs to be done.
Now that we’re able to hide away our impurities and still work with the results, we’ll load slides for a presentation into our webapp using a containerized API, sort them with pure functions in a composition, and then display the slides using the JSX Virtual DOM suite built in Volume One.
State is a critical part of our applications. Over the history of the Web, sites have evolved into complex applications, but only recently have most of us come to understand why state in a web app would benefit from patterns such as Flux or Redux. These patterns make state predictable.
We’ve discussed the various troubles that working with state can bring. We even discussed the benefits to working with a single object data store. Now we’ll create a data store like Redux
Debugging applications can be tricky. Functional programming teaches us that pure/deterministic code shouldn’t have funky, hard to track bugs, but how can we easily track bugs that occur at different points in time, over changes to our apps state?
Now that we can use the Redux-ish store in our app, it’s time that we allow the user to interact with our application. This will require us to integrate events that dispatch actions from our JSX to our Redux-ish store
Packt has been committed to developer learning since 2004. A lot has changed in software since then - but Packt has remained responsive to these changes, continuing to look forward at the trends and tools defining the way we work and live. And how to put them to work.
With an extensive library of content - more than 4000 books and video courses -Packt's mission is to help developers stay relevant in a rapidly changing world. From new web frameworks and programming languages, to cutting edge data analytics, and DevOps, Packt takes software professionals in every field to what's important to them now.
From skills that will help you to develop and future proof your career to immediate solutions to every day tech challenges, Packt is a go-to resource to make you a better, smarter developer.
Packt Udemy courses continue this tradition, bringing you comprehensive yet concise video courses straight from the experts.