Functor

In the previous chapter, we discussed the situation in which we wanted to combine elements inside of a container. We found out that abstractions such as Reducible and Foldable can help with that by taking a function of two arguments and bringing it into the container so that it can be applied on pairs of elements inside of it. As an example, we showed you how this approach makes it possible to implement different survival strategies for a bucket of fish.

What we haven't covered is a case where we don't want to combine elements in the container but do something with all of them, a single element at a time. This is the bread and butter of functional programming—applying pure functions to arguments and getting the results back, then ...

Get Learn Scala 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.