title: Why does adding a tilde in front of a pattern match slow my function down?
body: <p>I have two functions defined in a piece of haskell code:</p>
  
  <pre><code>lengthwtilde [] = 0
  lengthwtilde ~(_:xs) = 1 + lengthwtilde xs
  
  lengthwotilde [] = 0
  lengthwotilde (_:xs) = 1 + lengthwotilde xs
  </code></pre>
  
  <p>When I test them both out in ghci (using <code>:set +s</code>), I find that <code>lengthwtilde</code> (the one with a tilde in front of the pattern match) performs significantly slower than <code>lengthwotilde</code> by about three seconds.</p>
  
  <pre><code>*Main&gt; lengthwtilde [1..10000000]
  10000000
  (19.40 secs, 1731107132 bytes)
  *Main&gt; lengthwotilde [1..10000000]
  10000000
  (16.45 secs, 1531241716 bytes)
  </code></pre>
  
  <p>Why is this?</p>