I asked this question a while ago. It was about the following arrow law:
arr fst . first f = f . arr fst -- (.) :: Category k => k b c -> k a b -> k a c
In the comments under the post Asad Saeeduddin explained it in terms of natural transformations. I would like to check whether I got their explanation right and compare it a bit to Bartosz Milewski's article on natural transformations.
So, the definition of natural transformations goes:
We have two categories C and D and functors F, G : C ~> D. A natural transformation α is a family of arrows in D such that:
- These arrows go from the results of
Fto the results ofG. That is, for every objectainCthere exists an arrow (called the component ofαata)α_a :: F a ~> G a. - For every
f :: a ~> b,aandbbeing objects inC, holds:Gf . α_a = α_b . Ff. That is the naturality.
Basically, we need to figure what four variables are in our case: C, D, F and G.
As far as I get it:
CandDare the same category of arbitrary types,k a bbeing arrows in it, wherekis theArrowinstance we are working with. Therefore,FandGare endofunctors.Fis(, c)andGisIdentity. In other words, if we no longer work with types, we mapFwithfirstandGwithid. It would probably be easier NOT to think in terms of types as theCategoryandArrowclasses help us construct category's arrows, not objects
Is this right?
Moreover, Bartosz Milewski wrote those ideas down like that:
fmap f . alpha = alpha . fmap f
As far as I get it, we need a more general form for our purposes as here alpha :: forall a. F a -> G a deals with Hask only as the category it works with. Or am I wrong? Which place does fmap have in this picture?