Traverse

Previously, we learned about the Applicative type class. We argued that the main utility of the Applicative type class is that it allows us to combine two independent computations in parallel. No longer are we bound by the flatMap function that performs sequential composition, so that if one computation fails then no other computation is ever performed. In the Applicative scenario, all of the computations are performed, despite the fact that some of them can fail.

However, Applicative is only able to combine two independent computations. There are also methods to combine up to 22 computations into tuples. However, what if we need to combine an arbitrary amount of computations? The usual generalization for multiplicity is collections. ...

Get Mastering Functional Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.