3 ms·
A category is just a grouping of mappings that have something in common. When we say "in the category of endofunctors" what we are saying is "consider the grou
by mikekchar 8y ago
A category is just a grouping of mappings that have something in common. When we say "in the category of endofunctors" what we are saying is "consider the grouping of mappings where in the source set and the target set are the same". The "source set" is the set of possible values for the input of the fmap function -- in other words the type of the input parameter. The "target set" is the set of possible values for the output of the fmap function -- in other words the type of the return value. So if you have a container that contains a certain type of data and you can call fmap and it returns the same container with the same type of data, then it can be an endofunctor.
Remember that we are talking about the "category of endofunctors", so it's basically saying "We are talking about operations where you start with a certain type and you return values of the same type". In that way, any monoid is a monad when you return the same type as you started with. You can't use it as a monad in a different context. In Haskell the compiler forbids you from doing it, but it's easy to get it wrong in a langues without static type checking (to much hilarity).
Long story short, using a functor with bind is an endofunctor. Using a functor with map is an endofunctor if your transforming function doesn't change its type, but it's not guaranteed.