Hands-On Functional Programming with TypeScript
eBook - ePub

Hands-On Functional Programming with TypeScript

Explore functional and reactive programming to create robust and testable TypeScript applications

Remo H. Jansen

Buch teilen
  1. 210 Seiten
  2. English
  3. ePUB (handyfreundlich)
  4. Über iOS und Android verfügbar
eBook - ePub

Hands-On Functional Programming with TypeScript

Explore functional and reactive programming to create robust and testable TypeScript applications

Remo H. Jansen

Angaben zum Buch
Buchvorschau
Inhaltsverzeichnis
Quellenangaben

Über dieses Buch

Discover the power of functional programming, lazy evaluation, monads, concurrency, and immutability to create succinct and expressive implementations

Key Features

  • Get a solid understanding of how to apply functional programming concepts in TypeScript
  • Explore TypeScript runtime features such as event loop, closures, and Prototypes
  • Gain deeper knowledge on the pros and cons of TypeScript

Book Description

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.

What you will learn

  • Understand the pros and cons of functional programming
  • Delve into the principles, patterns, and best practices of functional and reactive programming
  • Use lazy evaluation to improve the performance of applications
  • Explore functional optics with Ramda
  • Gain insights into category theory functional data structures such as Functors and Monads
  • Use functions as values, so that they can be passed as arguments to other functions

Who this book is for

This book is designed for readers with no prior experience of functional programming with JavaScript, TypeScript or any other programming language. Some familiarity with TypeScript and web development is a must to grasp the concepts in the book easily.

Häufig gestellte Fragen

Wie kann ich mein Abo kündigen?
Gehe einfach zum Kontobereich in den Einstellungen und klicke auf „Abo kündigen“ – ganz einfach. Nachdem du gekündigt hast, bleibt deine Mitgliedschaft für den verbleibenden Abozeitraum, den du bereits bezahlt hast, aktiv. Mehr Informationen hier.
(Wie) Kann ich Bücher herunterladen?
Derzeit stehen all unsere auf Mobilgeräte reagierenden ePub-Bücher zum Download über die App zur Verfügung. Die meisten unserer PDFs stehen ebenfalls zum Download bereit; wir arbeiten daran, auch die übrigen PDFs zum Download anzubieten, bei denen dies aktuell noch nicht möglich ist. Weitere Informationen hier.
Welcher Unterschied besteht bei den Preisen zwischen den Aboplänen?
Mit beiden Aboplänen erhältst du vollen Zugang zur Bibliothek und allen Funktionen von Perlego. Die einzigen Unterschiede bestehen im Preis und dem Abozeitraum: Mit dem Jahresabo sparst du auf 12 Monate gerechnet im Vergleich zum Monatsabo rund 30 %.
Was ist Perlego?
Wir sind ein Online-Abodienst für Lehrbücher, bei dem du für weniger als den Preis eines einzelnen Buches pro Monat Zugang zu einer ganzen Online-Bibliothek erhältst. Mit über 1 Million Büchern zu über 1.000 verschiedenen Themen haben wir bestimmt alles, was du brauchst! Weitere Informationen hier.
Unterstützt Perlego Text-zu-Sprache?
Achte auf das Symbol zum Vorlesen in deinem nächsten Buch, um zu sehen, ob du es dir auch anhören kannst. Bei diesem Tool wird dir Text laut vorgelesen, wobei der Text beim Vorlesen auch grafisch hervorgehoben wird. Du kannst das Vorlesen jederzeit anhalten, beschleunigen und verlangsamen. Weitere Informationen hier.
Ist Hands-On Functional Programming with TypeScript als Online-PDF/ePub verfügbar?
Ja, du hast Zugang zu Hands-On Functional Programming with TypeScript von Remo H. Jansen im PDF- und/oder ePub-Format sowie zu anderen beliebten Büchern aus Informatik & Programmierung in JavaScript. Aus unserem Katalog stehen dir über 1 Million Bücher zur Verfügung.

Information

Jahr
2019
ISBN
9781788838184

Category Theory

In the previous chapter, we learned about functions, asynchronous programming, and the runtime and functional programming principles and techniques, including pure functions and functional composition.
In this chapter, we are going to focus on category theory and algebraic data types. We are going to learn about the following concepts:
  • Category theory
  • Algebraic data types
  • Functors
  • Applicative
  • Maybe
  • Either
  • Monads

Category theory

Functional programming has a reputation for being difficult to learn and understand due to its mathematical background. Functional programming languages and design patterns are influenced by concepts that originated in different mathematical fields. However, we can highlight category theory as one of the most significant influences. We can think about category theory as an alternative to set theory. It defines the theory behind a series of data structures or objects known as algebraic data types.
There are many algebraic data types, and understanding all the properties and rules that they must implement requires a significant amount of time and effort. The following diagram illustrates the relationships between some of the most common algebraic data types:
The arrows in the diagram indicate that a given algebraic data type must implement the specification of some other algebraic data types. For example, the Monad type must implement the specifications of the Applicative and Chain types.
The open source project, fantasy-land, declares a specification for some of these algebraic data types. The open source project, ramda-fantasy, implements these specifications in a way that is compatible with Ramda, which is a popular functional programming library that we will explore later in this book.
The algebraic data type specifications can be implemented in many ways. For example, the Functor specification can be implemented by a Maybe or an Either data type. Both types implement the Functor specification, but can also implement other specifications, such as the Monad or the Applicative specification.
The following table describes which specifications (listed in the top row) are implemented by one of the algebraic data type implementations (left row) in the fantasy-ramda project:
Name Setoid Semigroup Functor Applicative Monad Foldable ChainRec
Either
Future
Identity
IO
Maybe
Reader
Tuple
State
Understanding the field of category theory and all these data types and specifications is outside the scope of this book. However, in this chapter, we are going to learn the basics regarding two of the most common algebraic data types: Functors and Monads.
Please refer to the fantasy-land project at https://github.com/fantasyland/fantasy-land and the fantasy-ramda project at https://github.com/ramda/ramda-fantasy to learn more about algebraic data types.

Functors

The Functor type has two main characteristics:
  • It holds a...

Inhaltsverzeichnis