Book Image

Hands-On Functional Programming with TypeScript

By : Remo H. Jansen
Book Image

Hands-On Functional Programming with TypeScript

By: Remo H. Jansen

Overview of this book

Functional programming is a powerful programming paradigm that can help you to write better code. However, learning functional programming can be complicated, and the existing literature is often too complex for beginners. This book is an approachable introduction to functional programming and reactive programming with TypeScript for readers without previous experience in functional programming with JavaScript, TypeScript , or any other programming language. The book will help you understand the pros, cons, and core principles of functional programming in TypeScript. It will explain higher order functions, referential transparency, functional composition, and monads with the help of effective code examples. Using TypeScript as a functional programming language, you’ll also be able to brush up on your knowledge of applying functional programming techniques, including currying, laziness, and immutability, to real-world scenarios. By the end of this book, you will be confident when it comes to using core functional and reactive programming techniques to help you build effective applications with TypeScript.
Table of Contents (14 chapters)
5
The Runtime – Closures and Prototypes

What this book covers

Chapter 1, Functional Programming Fundamentals, introduces the main functional programming terms, such as pure functions.

Chapter 2, Mastering Functions, takes an in-depth look at the main building block in a functional programming application—functions. The chapter also explores most of the function-related features in TypeScript. We will learn how to work with functions in many different scenarios and how to take advantage of the TypeScript type system features while working with functions.

Chapter 3, Mastering Asynchronous Programming, takes an in-depth look at the main asynchronous programming APIs in JavaScript and TypeScript, including callbacks, promises, generators, and asynchronous functions. These APIs are relevant in functional programming because they can be used to implement lazy evaluation.

Chapter 4, The Runtime – The Event Loop and the this Operator, is the first chapter of two that are dedicated to exploring concepts about the runtime that are relevant for a number of functional programming techniques. For example, we can gain a much better understanding of recursion if we understand the event loop.

Chapter 5, The Runtime – Closures and Prototypes, is the second chapter dedicated to exploring concepts about the runtime that are relevant to a number of functional programming techniques. For example, understanding closures can help us to understand how some higher-order functions work.

Chapter 6, Functional Programming Techniques, explores the main functional programming techniques and patterns in detail. We will explore concepts such as partial function application, functional composition, and currying. This chapter also explores many other functional programming techniques and patterns, such as point-free style.

Chapter 7, Category Theory, explores category theory. You will learn about what algebraic data types are and what the relationships between them are. You will then learn how to implement some of the main algebraic data types, including functors and monads.

Chapter 8, Immutability, Optics, and Laziness, explores three important functional programming techniques. You will learn about what lazy evaluation is, what its benefits are, and how to implement it. You will also learn about immutable data structures, their benefits, and how to implement them. Finally, you will learn about functional optics and how they can help with immutable data structures.

Chapter 9, Functional-Reactive Programming, explores the functional-reactive programming paradigm. We will learn about what observables are and how they can be used to simplify our code. We will also learn how to use RxJS, the leading reactive-programming library in the JavaScript ecosystem.

Chapter 10, Real-World Functional Programming, explores some production-ready functional programming libraries, such as Ramda and Funfix, to create real-world functional programming applications.\

Appendix A, Functional Programming Learning Road Map, this was developed for Fantasyland institute of learning for the LambdaConf conference. It is used to track our level of knowledge regarding functional programming.

Appendix B, Directory of TypeScript Functional Programming Libraries, In this appendix, you will find a list of functional programming libraries compatible with TypeScript grouped.