Asynchronous functional javascript
Asynchronous functional javascript
$4.99
Minimum price
$4.99
Suggested price
Asynchronous functional javascript

This book is 90% complete

Last updated on 2020-04-29

About the Book

This is a book about asynchronous javascript from the unifying perspective of category theory and functional programming.

A 5 installment is in progress that will include a chapter in Reactive Extensions with Rx.js.

Note: This is not an Introductory book in Asynchronous Javascript. The reader must have at least a couple of years of Javascript experience. Please read the Sample pdf to get an idea about the content of the book.

included Js source code for selected sections like Fluture.js and Folktale.js

About the Author

dimitris papadimitriou
dimitris papadimitriou

I have more than 14 years’ experience as full stack developer and Architect.

I Like to stay in touch with all the latest developments in the field, as well as the foundational Theoretical Computer science and algorithm Analysis and Design

https://www.linkedin.com/in/dimitrispapadimitriou/

Bundles that include this book

Functional Programming in Javascript
 Functional Programming in TypeScript
Asynchronous functional javascript
$20.99
Suggested Price
$14.99
Bundle Price

Table of Contents

  • 1 Introduction to Asynchrony
    • 1.1 Concurrency, Parallelism, Asynchrony ... 12
    • 1.1.1 Concurrency ... 12
    • 1.1.2 Parallelism ... 12
    • 1.1.3 Threads ... 12
    • 1.1.4 Synchronous and Asynchronous ... 13
    • 1.2 The Problem of Asynchrony ... 14
    • 1.3 The JavaScript Event Loop ... 14
    • 1.4 Callbacks ... 18
    • 1.5 The Continuation monad ... 18
    • 1.6 Promises ... 19
    • 1.7 Async-Await ... 19
    • 1.8 Events ... 20
    • 1.9 The basic Criteria of Comparison ... 22
  • 2 Callbacks
    • 2.1 Continuation Passing Style Transformation ... 24
    • 2.2 Continuations and Callbacks ... 25
    • 2.3 Callbacks Example. ... 26
    • 2.4 Including Error Handling ... 28
    • 2.5 The Continuation (a → r) → r Type ... 29
    • 2.6 Applying a function ... 32
    • 2.6.1 Callbacks ... 33
    • 2.6.2 The Continuation ... 34
    • 2.7 Sequential and Parallel execution ... 34
  • 3 Why Functional Programming
    • 3.1 Categories ... 35
    • 3.1.1 One-minute Functors ... 37
    • 3.1.2 The Identity Functor ... 38
    • 3.1.3 The Basic Functor Mechanics ... 39
    • 3.1.4 A brief mentioning of Pattern Matching ... 39
    • 3.1.5 The Asynchronous identity functor ... 40
    • 3.1.6 Pattern Matching for Hierarchies ... 41
    • 3.1.7 Adding Pattern Matching extensions Hierarchies ... 42
    • 3.1.8 Rewriting Subtype methods with matchWith ... 42
    • 3.1.9 Pattern Matching on Callbacks? ... 43
    • 3.1.10 Pattern Matching on Continuations? ... 45
    • 3.2 Either Functor ... 45
    • 3.2.1 Using Either for exception handling ... 47
    • 3.2.2 Either Functor Example ... 49
    • 3.3 The one Minute introduction to monads ... 50
    • 3.4 Either Monad ... 51
    • 3.4.1 Using Either Monad exception handling ... 52
    • 3.5 Showcase – Bind for Some Async Structures ... 54
    • 3.5.1 Monoids ... 54
    • 3.5.2 Multiplying stuff ... 55
    • 3.6 Composing Continuations ... 58
    • 3.6.1 The Continuation monad ... 59
    • 3.7 Folding Callbacks and Continuations ... 60
  • 4 Promises
    • 4.2 Creating promises ... 64
    • 4.2.1 The Promise executor as Union Type ... 64
    • 4.3 Extending Custom Promise to a Functor ... 66
    • 4.4 Extending Custom Promise to Monad ... 67
    • 4.5 Promisify Callback code ... 68
    • 4.6 Dissecting the Promise.then method ... 69
    • 4.6.1 The then as map ... 70
    • 4.6.2 The then as a monadic Bind ... 71
    • 4.6.3 The (then, catch) as pattern matching ... 72
    • 4.6.4 Conclusion ... 74
    • 4.6.5 Another Example of the monadic composition ... 74
    • 4.6.6 Promises and the Either Monad ... 76
    • 4.7 Parallel Execution ... 79
    • 4.7.1 Promise.all ... 81
    • 4.7.2 Promise.all Example ... 83
    • 4.7.3 Promise.race ... 84
    • 4.8 Thenables and PromiseLike ... 84
    • 4.9 Combining Promises and Either ... 85
    • 4.10 Combining Promises and Either - Example ... 87
    • 6.1.1 Error handling ... 98
  • 5 Fluture.js and Futures... 90
    • 6 Folktale.js and Tasks ... 93
      • 6 Web Workers for Parallelism ... 93
        • 6.1.2 Abstracting Workers with Promises ... 98
        • 6.2 Monoids ... 99
        • 6.2.1 Folding monoids ... 102
        • 6.2.2 Monoid homomorphisms and Parallelism ... 102
      • 7 Async-Await
        • 7.1 Async ... 109
        • 7.2 The await keyword ... 110
        • 7.3 Error handling ... 111
        • 7.4 Refactoring Promises to Async/await ... 111
        • 7.5 Sequential and Parallel execution ... 113
        • 7.5.1 Promise.all Example refactoring ... 114
      • 8 Apendix A- Algebraic Data Types
        • 8.1 The product structure: ... 117
        • 8.1.1 Introduction / Elimination ... 118
        • 8.2 The co-product (aka Union) structure: ... 119
        • 8.2.1 Introduction / Elimination ... 121

      Authors have earned$9,419,502writing, publishing and selling on Leanpub,
      earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.

      Learn more about writing on Leanpub

      The Leanpub 45-day 100% Happiness Guarantee

      Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

      See full terms

      Free Updates. DRM Free.

      If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

      Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.

      Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

      Learn more about Leanpub's ebook formats and where to read them

      Write and Publish on Leanpub

      You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses! Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks. Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. It really is that easy.

      Learn more about writing on Leanpub