Also, based on the type signature, how is the implementation (<*>)(<*>) = ?? will be?
It is easier to reverse the order (first find the implementation, and then enter its type).
Applicative instance for functions
instance Applicative ((->) a) where pure = const (<*>) fgx = fx (gx)
So, simply replacing <*> with f in the above definition, (<*>) (<*>) - \gx -> x <*> gx . Or after the alpha transform \gh -> h <*> gh .
Since the first argument (<*>) is h , it must be of type h :: f (a -> b) for some a and b , where f is in Applicative .
Since g takes h as an argument, it must be of type g :: f (a -> b) -> c for some c .
Since the first argument (<*>) , h is of type f (a -> b) , and the second argument (<*>) is gh , its type must be gh :: fa , because
(<*>) :: f (a -> b) -> fa -> fb
Since g :: f (a -> b) -> c and gh :: fa ,
h :: f (a -> b) g :: f (a -> b) -> c gh :: fa , c ~ fa (!)
Since h is of type f (a -> b) , h <*> (whatever :: fa) is of type fb .
And generally speaking:
h :: f (a -> b) g :: f (a -> b) -> fa h <*> gh :: fb
So we have
\gh -> h <*> gh :: (f (a -> b) -> fa) -> f (a -> b) -> fb