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

Partager le livre
  1. 210 pages
  2. English
  3. ePUB (adapté aux mobiles)
  4. Disponible sur iOS et Android
eBook - ePub

Hands-On Functional Programming with TypeScript

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

Remo H. Jansen

DĂ©tails du livre
Aperçu du livre
Table des matiĂšres
Citations

À propos de ce livre

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.

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans paramĂštres et de cliquer sur « RĂ©silier l’abonnement ». C’est aussi simple que cela ! Une fois que vous aurez rĂ©siliĂ© votre abonnement, il restera actif pour le reste de la pĂ©riode pour laquelle vous avez payĂ©. DĂ©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptĂ©s aux mobiles peuvent ĂȘtre tĂ©lĂ©chargĂ©s via l’application. La plupart de nos PDF sont Ă©galement disponibles en tĂ©lĂ©chargement et les autres seront tĂ©lĂ©chargeables trĂšs prochainement. DĂ©couvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accĂšs complet Ă  la bibliothĂšque et Ă  toutes les fonctionnalitĂ©s de Perlego. Les seules diffĂ©rences sont les tarifs ainsi que la pĂ©riode d’abonnement : avec l’abonnement annuel, vous Ă©conomiserez environ 30 % par rapport Ă  12 mois d’abonnement mensuel.
Qu’est-ce que Perlego ?
Nous sommes un service d’abonnement Ă  des ouvrages universitaires en ligne, oĂč vous pouvez accĂ©der Ă  toute une bibliothĂšque pour un prix infĂ©rieur Ă  celui d’un seul livre par mois. Avec plus d’un million de livres sur plus de 1 000 sujets, nous avons ce qu’il vous faut ! DĂ©couvrez-en plus ici.
Prenez-vous en charge la synthÚse vocale ?
Recherchez le symbole Écouter sur votre prochain livre pour voir si vous pouvez l’écouter. L’outil Écouter lit le texte Ă  haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l’accĂ©lĂ©rer ou le ralentir. DĂ©couvrez-en plus ici.
Est-ce que Hands-On Functional Programming with TypeScript est un PDF/ePUB en ligne ?
Oui, vous pouvez accĂ©der Ă  Hands-On Functional Programming with TypeScript par Remo H. Jansen en format PDF et/ou ePUB ainsi qu’à d’autres livres populaires dans Informatik et Programmierung in JavaScript. Nous disposons de plus d’un million d’ouvrages Ă  dĂ©couvrir dans notre catalogue.

Informations

Année
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...

Table des matiĂšres