Meeting Profunctors
So far in the book I’ve always presented functional programming concepts as solutions to specific problems. But now we’re near the end, and for once, we can take a more theoretical approach—let’s try to identify our abstraction after we’ve already solved the problem!
The risk with the theoretical approach is that it introduces unnecessary abstractions, but sometimes that can be illuminating and very useful in the long term. So, let’s have some fun together and try to carve out a functor from our converters.
We define a converter as the union of two functions, and we learned that a functor is defined by the transform operation.
Let’s try to define a type, FromJsonF, that would work as functor for the parsing operation. Have ...
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.
Read now
Unlock full access