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

Condividi libro
  1. 210 pagine
  2. English
  3. ePUB (disponibile sull'app)
  4. Disponibile su iOS e Android
eBook - ePub

Hands-On Functional Programming with TypeScript

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

Remo H. Jansen

Dettagli del libro
Anteprima del libro
Indice dei contenuti
Citazioni

Informazioni sul libro

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.

Domande frequenti

Come faccio ad annullare l'abbonamento?
È semplicissimo: basta accedere alla sezione Account nelle Impostazioni e cliccare su "Annulla abbonamento". Dopo la cancellazione, l'abbonamento rimarrà attivo per il periodo rimanente già pagato. Per maggiori informazioni, clicca qui
È possibile scaricare libri? Se sì, come?
Al momento è possibile scaricare tramite l'app tutti i nostri libri ePub mobile-friendly. Anche la maggior parte dei nostri PDF è scaricabile e stiamo lavorando per rendere disponibile quanto prima il download di tutti gli altri file. Per maggiori informazioni, clicca qui
Che differenza c'è tra i piani?
Entrambi i piani ti danno accesso illimitato alla libreria e a tutte le funzionalità di Perlego. Le uniche differenze sono il prezzo e il periodo di abbonamento: con il piano annuale risparmierai circa il 30% rispetto a 12 rate con quello mensile.
Cos'è Perlego?
Perlego è un servizio di abbonamento a testi accademici, che ti permette di accedere a un'intera libreria online a un prezzo inferiore rispetto a quello che pagheresti per acquistare un singolo libro al mese. Con oltre 1 milione di testi suddivisi in più di 1.000 categorie, troverai sicuramente ciò che fa per te! Per maggiori informazioni, clicca qui.
Perlego supporta la sintesi vocale?
Cerca l'icona Sintesi vocale nel prossimo libro che leggerai per verificare se è possibile riprodurre l'audio. Questo strumento permette di leggere il testo a voce alta, evidenziandolo man mano che la lettura procede. Puoi aumentare o diminuire la velocità della sintesi vocale, oppure sospendere la riproduzione. Per maggiori informazioni, clicca qui.
Hands-On Functional Programming with TypeScript è disponibile online in formato PDF/ePub?
Sì, puoi accedere a Hands-On Functional Programming with TypeScript di Remo H. Jansen in formato PDF e/o ePub, così come ad altri libri molto apprezzati nelle sezioni relative a Informatik e Programmierung in JavaScript. Scopri oltre 1 milione di libri disponibili nel nostro catalogo.

Informazioni

Anno
2019
ISBN
9781788838184
Edizione
1
Argomento
Informatik

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...

Indice dei contenuti