title: Non-exhaustive patterns in function
body: <p>I've got a problem with this code, it should count the longest substring of the same letter in a string, but there is an error:</p>
  
  <pre><code>*** Exception: test.hs:(15,0)-(21,17): 
  Non-exhaustive patterns in function countLongest'
  </code></pre>
  
  <p>I know that is the wrong types problem, but i dont know where is the error, or how to find or debug it</p>
  
  <pre><code>countLongest :: (Eq a) =&gt; [a] -&gt; Int
  countLongest' :: (Eq a) =&gt; Int -&gt; Int -&gt; [a] -&gt; Int
  
  countLongest a = countLongest' 0 0 a
  countLongest' n max (y:x:ys)
          | y == x = countLongest' (n+1) max (x:ys)
          | n &gt; max = countLongest' 0 (n) (x:ys)
          | otherwise = countLongest' 0 (max) (x:ys)
  countLongest' n max []
          | n &gt; max = n
          | otherwise = max
  </code></pre>