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

Blocking example

First, let's take a look at the API behind creating an asynchronous IO action:

So, you can supply an arbitrary task into an apply method of IO, and this will construct the description of this task.

We can model blocking of a computation by using the Thread.sleep Java API under the IO apply method as follows:

IO { Thread.sleep(1000) }

Notice that the preceding example will block its thread. IO may be just a description of a computation. However, the computations are supposed to get executed at some point. In the JVM world, any computation runs on a thread. In the preceding example, we are using the Java Thread.sleep API to ...

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