title: Understanding the functions elem and isInfixOf
body: <p>A while ago I've asked a question about the function <code>elem</code> <a href="https://stackoverflow.com/questions/7619217/compare-lists-in-haskell">here</a>, but I don't think the answer is fully satisfactory. My question is about the expression:</p>
  
  <pre><code>any (`elem` [1, 2]) [1, 2, 3]
  </code></pre>
  
  <p>We know <code>elem</code> is in a backtick so <code>elem</code> is an infix and my explanation is:</p>
  
  <pre><code>1 `elem` [1, 2] -- True
  2 `elem` [1, 2] -- True
  3 `elem` [1, 2] -- False
  </code></pre>
  
  <p>Finally it will return <code>True</code> since it's <code>any</code> rather than <code>all</code>. This looked good until I see a similar expression for <code>isInfixOf</code>:</p>
  
  <pre><code>any (isInfixOf [1, 2, 3]) [[1, 2, 3, 4], [1, 2]]
  </code></pre>
  
  <p>In this case a plausible explanation seems to be:</p>
  
  <pre><code>isInfixOf [1, 2, 3] [1, 2, 3, 4] -- True
  isInfixOf [1, 2, 3] [1, 2]       -- False
  </code></pre>
  
  <p>I wonder why they've been used in such different ways since</p>
  
  <pre><code>any (elem [1, 2]) [1, 2, 3]
  </code></pre>
  
  <p>will give an error and so will </p>
  
  <pre><code>any (`isInfixOf` [[1, 2, 3, 4], [1, 2]]) [1, 2, 3]
  </code></pre>