3 ms·
In general, if your reaction to finally understanding "functors" is "so what?", there's a reasonably good chance that means you've actually understood them: htt
by jerf 3y ago
In general, if your reaction to finally understanding "functors" is "so what?", there's a reasonably good chance that means you've actually understood them: https://jerf.org/iri/post/2958/ https://jerf.org/iri/post/2958/
The useful thing about functors isn't that they are particularly complicated, it is that they are a useful interface to be able to write things generically over. It's very similar to iterators. Being able to present items out of some collection one at a time is "so what?" It is not interesting on its own. But having a common interface over them allows for a lot of good code to be written that you can't write in a language that lacks them, and have to one-off ad-hoc all the time.
That a Parser is a Functor means you can apply all the functor tools in writing them. This is one of the appeals of parser combinators, which is again not that they are some sort of brilliant insight on their own, but that they work well with the generalized tools rather than needing specific implementations of them.
- deleted 3y ago[deleted]
- 4death4 3y agoIf your reaction to iterators is “so what?” then I would say you fundamentally don’t understand computation. Asking “so what?” about iterators has plenty of useful answers that will aide you in programming. The same is not really true about functors.
- jerf 3y agoThe linked article goes into detail about what I mean about that, but what I mean is that some of these concepts have a lot of mystery around them that are not deserved. Many people penetrate this mystery and then wonder what the deal was with the mystery. For these particular concepts, that's generally a good sign. Iterators are important... but they are not conceptually complicated. They're just a way of getting a "next element". Behind that may be a lot of complexity for some particular iterator, but that complexity should be accounted to the implementation, not the concept of iterator.
- 4death4 3y ago> Iterators are important... but they are not conceptually complicated. To me, the essence of asking “so what?” is primarily about importance not complexity. When you ask “so what?” You’re essentially asking “Why should I care? What can this do for me?” It doesn’t really matter whether or not the subject is complex.