4 ms·
I'm not going to be able to explain functors and monads in one post. That's kind of what led to Brent Yorgey's famous post with burritos. [0] What I can do is
by Twisol 5y ago
I'm not going to be able to explain functors and monads in one post. That's kind of what led to Brent Yorgey's famous post with burritos. [0]
What I can do is try to work with somebody at the level they're prepared for, and at least try to show what functors are meant for. If you know what functors are, you're not really my target audience; I won't be able to meet your expectations.
In the past, I've discussed functors as unary pipelines (applicatives are n-ary) [1] [5], as ways of viewing one world of widgets within another [2], as generalized "sources" (generic over whatever they produce) [3], and as what they are in the most abstract sense: a pair of morphisms [4].
I didn't think any of those explanations were suitable starting from a C/assembly level, since you cannot represent most forms of parametricity in the first place. Instead, I tried to take a concrete issue you might run into in C, and motivate the reason you'd want to use functors to solve it. You cannot represent functors in C; you can't even write a single generic `map`, which is the most visible witness of a functor in most languages. Discussing any form of concretized Functor trait would be putting the cart before the horse.
Bonus primers on lenses [6] and monoids [7] if you like.
[0] https://byorgey.wordpress.com/2009/01/12/abstraction-intuition-and-the-monad-tutorial-fallacy/ https://byorgey.wordpress.com/2009/01/12/abstraction-intuiti...
[1] https://news.ycombinator.com/item?id=28476843 https://news.ycombinator.com/item?id=28476843
[2] https://news.ycombinator.com/item?id=28549934 https://news.ycombinator.com/item?id=28549934
[3] https://news.ycombinator.com/item?id=28479315 https://news.ycombinator.com/item?id=28479315
[4] https://news.ycombinator.com/item?id=28476667 https://news.ycombinator.com/item?id=28476667
[5] https://news.ycombinator.com/item?id=27649493 https://news.ycombinator.com/item?id=27649493
[6] https://news.ycombinator.com/item?id=26783570 https://news.ycombinator.com/item?id=26783570
[7] https://news.ycombinator.com/item?id=27180675 https://news.ycombinator.com/item?id=27180675