title: Who can explain this Haskell puzzle?
body: <p>I'm aware that using the . operator chains functions together, like so:</p>
  
  <pre><code>isLessThanZero x 
     | x &lt; 0 = True
     | otherwise = False
  
  (isLessThanZero . negate) 3 -- Produces True
  </code></pre>
  
  <p>Or with $:</p>
  
  <pre><code>getNegNumbers x = map (*x) [-1, -2, -3]
  
  filter isLessThanZero $ getNegNumbers 2 -- Produces [-2, -4, -6]
  </code></pre>
  
  <p>But if I were to do something like:</p>
  
  <pre><code>(subtract . negate) 1 2 -- 3
  negate $ subtract 1 2 -- -1
  </code></pre>
  
  <p>The results here are different, and it doesn't make sense because the two functions accept a different number of arguments. With <code>.</code> the <code>negate</code> function checks whether a number is negative or not, but two arguments are supplied. It could imply that the expression is left-associative. </p>
  
  <pre><code>negate (subtract 1 2) -- -1
  (subtract . negate) 1 2 -- 3
  </code></pre>
  
  <p>But this is confusing because in the first example:</p>
  
  <pre><code>(isLessThanZero . negate) 3
  </code></pre>
  
  <p>The expression produces <code>True</code>, which implies that the function <code>negate</code> was executed first, then <code>isLessThanZero</code> is called. But in the latest example, it appears that <code>subtract</code> was called first and then <code>negate</code> was called. So I'm not sure what's going on here. But this is what's even more confusing:</p>
  
  <pre><code>subtract 1 2 -- Produces 1!
  </code></pre>
  
  <p>Which implies that the entire expression:</p>
  
  <pre><code>(subtract . negate) 1 2 -- Produces 3!
  </code></pre>
  
  <p>is a side-effect of using function chaining.</p>
  
  <p>My theory is this, decomposing thus:</p>
  
  <p>We know that 2 - (-1) = 3. So, the expression is still right-associative.. I think. <code>negate</code> is still called first like in the previous example, only that it affects the first argument, rather than both arguments, which makes sense because negate accepts only one argument, and we're not mapping the function at all. </p>
  
  <p>So, when it comes to chaining functions with differing number of arguments, how should Haskell respond to that?</p>