<$> (aka fmap ) is a member of the Functor class as follows:
class Functor f where fmap :: (a -> b) -> fa -> fb
Thus, any f must be a parameterized type with one type argument. Lists are one of those types when they are written in their prefix form [] ( [] a matches [a] ). So, an instance for lists:
instance Functor [] where -- fmap :: (a -> b) -> [] a -> [] b fmap = map
Pairs can also be written as a prefix: (,) ab matches (a, b) . Therefore, consider what we do if we want a Functor instance to include pairs. We cannot declare instance Functor (,) , because the constructor of the pair (,) takes two types - and they can be of different types! What we can do is declare an instance for (,) a - the type that is needed only for the following type:
instance Functor ( (,) a ) where -- fmap :: (b -> c) -> (,) ab -> (,) ac fmap f (x, y) = (x, fy)
Hopefully you will see that the definition of fmap is the only reasonable one we can give. The answer to the question why the functor instance works in the second element in the pair is that the type of the second element comes last in the list! We cannot easily declare an instance of a functor that works with the first element in a pair. By the way, this generalizes to large tuples, for example. four (,,,) abcd (aka (a, b, c, d) ) can also have a Functor instance for the last element:
instance Functor ( (,,,) abc) where -- fmap :: (d -> e) -> (,,,) abcd -> (,,,) abce fmap f (p, q, r, s) = (p, q, r, fs)
Hope this helps explain all this!