| Functors don't include tmap. Yes, a functor maps objects from one category to objects of the second, but it does so on the sets of objects. There might not be a corresponding morphism between "a" and "f a". The typeclass you created would be a functor along with a natural transformation from the identity functor to f. I don't think these always exist, but they do for applicative functors (pure/return). The object mapping is reflected at the type level. "f a" is the object that "f" sends "a" to. In Haskell, functors are all endofunctors. In math, functors can be between categories, and in such a case a -> f a might not make any sense because there are no morphisms between categories. Using some quasi-Agda syntax, here would be a full definition of a functor between two categories. Maybe you could overload "->" so that "X -> Y" could mean "Mor X Y" for the set of morphisms between X and Y in C or D (depending on context). Curly brackets mean optional parameters, which Haskell approximates via typeclasses. record Functor where
field
C, D : Cat
F : Ob C -> Ob D
fmap : {X Y : Ob C} -> Mor{C} X Y -> Mor{D} (F X) (F Y)
fmapId : {X : Ob C} -> fmap id == id
fmapComp : {X Y Z : Ob C} -> {f : Mor X Y} -> {g : Mor Y Z}
-> fmap g . fmap f == fmap (g . f)
|
In CAT the category of small categories objects are categories and morphisms are functors. Haskell types can be thought of as a small categories so I don't think this statement is correct? I'm no expert but can you clarify, the definition on wikipedia says that functors are morphisms between categories in CAT.
>There might not be a corresponding morphism between "a" and "f a".
Hmm. if haskell types make up a small category that means 'a' and 'f a' are sets. I can't imagine a case where two sets cannot have a mapping between them. Can you give a specific example?
>The typeclass you created would be a functor along with a natural transformation from the identity functor to f.
I'm confused about this. Isn't the natural transformation from identity to another category (at least for small categories) equivalent to a functor? In my head they look identical.
https://en.wikipedia.org/wiki/Natural_transformation
If you look at the commutative diagram on this page and replace F(X) and G(X) with identity X and G the natural transformation diagram looks just like a diagram for a functor.
btw I'm not an expert in haskell (let alone agda) or category theory so forgive me if the stuff I talk about is totally off.