Functor

Another frequently encountered type class in functional programming is Functor. Functor is all about the map function in its essence. As you may recall from the previous chapters, the map function is very similar to flatMap function; however, it takes a non-side effecting computation as its argument. It is used to transform a value within the context of a effect type when this transformation is not side effecting itself.

You might want to use a Functor if you want to do something with the result of a side effecting computation without extracting it from its effect type.

As you may recall, we used an intuition of sequential composition in the case of the flatMap of a Monad. This intuition may not be the best one for Functor. In the ...

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.