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

Asynchrony

Consider an example of a web server tasked with handling incoming HTTP requests in a setting of a web application that manages an online forum. Consider that the requests in question are to be responded to with the data about all of the forum posts present in the database. This means that in order to reply to any given HTTP request, we first need to obtain the required data from the database. The solution may look as follows:

def handle(request: Request): Response = {  val posts: List[Post] = allPosts()  respond(posts)}

In the preceding example, the types and methods are declared as follows:

type Requesttype Responsetype Postdef allPosts(): List[Post]def respond[A](a: A): Response

However, this is not the only task that our application ...

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