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

IO combination with Fibers

Previously, we briefly touched on the topic of Fibers. They are remote control units for underlying computations. We know that on any IO, we can call a start method, and that will cause it to run asynchronously, which means that it will not block the current execution flow of the IO effect type. Also, you know that we can later block on a Fiber in order to obtain the result. Notice that, here, we are blocking with respect to the Monadic flow. It is precisely the Monadic flow that is getting blocked, that is, the execution of the Monadic instructions gets suspended. The underlying thread IO used to run is not blocked by anything.

Let's see how we can implement our sum example with the help of Fibers:

def parallel: ...
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