Skip to Content
Mastering Functional Programming
book

Mastering Functional Programming

by Anatolii Kmetiuk
August 2018
Intermediate to advanced
380 pages
10h 2m
English
Packt Publishing
Content preview from Mastering Functional Programming

Composing Futures

A situation where we need to run one computation after another in an asynchronous manner is a frequent pattern. One way to solve this task is via callbacks, as we have seen previously. Every asynchronous computation is a separate entity and is started from a callback that's registered on another computation it depends upon.

Another way of conceptualizing such a pattern is to treat Futures as composable entities. The concept in question is the ability to compose two Futures into one. The semantics of the combined Future is a sequential execution of the second Future after the first one.

So, given a Future for contacting the database and a Future for contacting the weather forecast server, we can create a Future that combines ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Functional Programming

Learning Functional Programming

Jack Widman

Publisher Resources

ISBN: 9781788620796Supplemental Content