4 ms·
There are many many categories in Haskell. All you need for a category is to identify _something_ as the objects, _something_ as the arrows, and make sure your
by dwohnitmok 8y ago
There are many many categories in Haskell. All you need for a category is to identify _something_ as the objects, _something_ as the arrows, and make sure your identifications result in something that matches the category laws.
As a simple example, every monoid is a category with a single object (hence the mono- prefix). Hence every monoid in Haskell is a category.
Now it is true that all `Functor`s in the sense of the Haskell typeclass are endofunctors in category theory, because a higher-kinded type can be thought of as a mapping between types in Haskell (e.g. `Maybe` maps `Int` to the new type `Maybe Int`) and `fmap` can be thought of as a mapping of functions between types to their remapped types (we take `a -> b` and replace it with `Maybe a -> Maybe b`), which results in a functor from Hask to Hask.
However, it is not true that the only functors (in the category theory sense) are instances of the `Functor` typeclass.