I'm having trouble understanding how the function composition operator works in Haskell. I understand it in simple cases where you only use functions that takes one argument but I don't understand whats going on when you use it on several functions that each take more than one argument.
Consider this function:
f1 = (*) . (+) 2 $ 1
All this function does is that it takes a number and multiplies it with three so it's the same as:
f2 = (*) $ (+) 2 1
and
f3 = (*) 3
I understand exactly whats going on in f2 but I dont get what is going on in f1 that makes the two the same. The (.) takes two functions and a value, each of the functions can only take one argument so in this case both (*) and (+) has to be partially applied for things to work. What I don't understand is what they are applied to and how this is sent through the chain of functions.
In f2 (+) is first applied to both funtions producing a value that is partially applied to (*), creating a function. In f1 it is not possible for (+) to be assigned to both values since (.) requires a function as input, yet they are the same. I do not understand this.
I hope you understand what I'm having problems understanding. Thanks in advance!