3 ms·
You're right that calling a functor a container is an oversimplification. But when you start explaining something at full generality, it only makes sense to pe
by jrockway 17y ago
You're right that calling a functor a container is an oversimplification. But when you start explaining something at full generality, it only makes sense to people that already understand the full generality. Once you understand how List and Tree are similar, you can understand how List, Tree, Reader, and IO are similar. But if you don't see any connections between List and Tree, you are never going to see any connection between List and IO. So, you need to simplify, understand the simplification, and then try to attack full generality.
The same goes for monoids. Many people won't see any use for "identity + associative binary operator". But they will understand the similarities between "append to a list" and "add numbers". Once you see something concrete, then you can worry about abstraction. If you don't understand the concrete, though, you aren't going to get there from the abstraction.
(Nobody ever said, "I'll define a functor to be ... Now I'll write a program with this functor!" Instead, they noticed how lists and trees were similar, and invented the functor abstraction afterwards. If you learn and discover things the same way they did, you'll eventually have the same deep understanding they do. That understanding is what allows you to use the abstractions, not the definition you find in a textbook.)
So anyway, if you are teaching people Haskell, it's better to teach them the concrete. Once they understand that, you can amend the definition to be fully abstract. Then they will be comfortable with the abstraction and its applications.