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

The tailRecM method

Previously in this section, we touched on the tailRecM method briefly. It is pretty useful in certain situations, because it allows you to define loops in the context of an effect type. In this subsection, let's take a more detailed look at its signature and at how this method works:

Let's take a look at the arguments of this method. First of all, let's take a look at the second argument of this method, the f function. The function takes a raw value of type A, and the result of this function is an effect type, which is F[Either[A, B]].

Let's think about what we can do with this computation to make a loop out of it. Suppose ...

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