If you look at the type of (.)
as
(b2 -> c2) -> (a2 -> b2) -> (a2 -> c2)
then
b1 ~ (a2 -> b2)
b1 ~ (a2 -> c2)
so (b2 ~ c2)
then you can see the type of (foldr (.))
is
(a2 -> b2) -> [(b2 -> b2)] -> (a2 -> b2)
which is the type GHC derives.