# Inferring the type of (f .) in Haskell

If we have the following in Haskell:

f x y = x + y
:type f
f :: Num a => a -> a -> a


then GHC would report Num a1 => (a2 -> a1) -> a2 -> a1 -> a1 as the type for (f .). Would you please explain me the steps through which GHC comes to such conclusion?

• Note: Haskell specific question is off-topic here. – Apiwat Chantawibul Sep 28 '19 at 2:56
• First, (.) is an infix binary operator (.) :: (b -> c) -> (a -> b) -> a -> c. Next, (f .) is the same operator, but partially applied with the first argument. So, (f .) :: (a -> b) -> a -> c – Apiwat Chantawibul Sep 28 '19 at 2:59
• You can see that f is taken to provide something of type b -> c for the first argument of (.). But since you already define previously that f :: Num a => a -> a -> a. So GHC put bracket as f :: Num a => a -> (a -> a) to match the expected type b -> c – Apiwat Chantawibul Sep 28 '19 at 3:12
• @Apwit Thank you for your clear answer. But for my question being off-topic I just used Haskell as an expressing platform, and my question was generally about inferring the type in general. Thanks again. – al pal Sep 28 '19 at 17:17