title: Error: Non-exhaustive patterns in Haskell
body: <p>I have some code that deals with a list of lists (that represents a matrix). Each cell is an <code>N</code> or a <code>B</code>. I want to represent the matrix with the number of <code>N</code>s for each line. For example: <code>[[B,B,N],[N,N,N]]</code> is represented by <code>[1,3]</code>.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>data Case = B|N deriving (Show, Eq)
  type Grille =[[Case]]
  
  g0,g1 :: Grille
  g0 = [[B,B,B,B,B,B,N],[B,B,N,B,N,B,B],[N,B,N,N,N,N,N],[B,B,B,N,N,B,N],[N,N,N,B,B,B,B],[B,B,B,N,N,B,N]]
  g1 = [[B,B,B,B,B,B,B],[B,B,N,N,N,B,B],[B,B,N,N,N,N,N],[B,B,B,N,N,N,N],[N,N,N,B,B,B,B],[B,B,B,N,B,B,B]]
  
  projH :: Grille -&gt; [Int]
  projH [[]] = []
  projH (x:xg) = testCase(x) ++ projH(xg)
  
  testCase :: [Case] -&gt; [Int]dans une ligne
  testCase [] = [0]
  testCase (x:xs) 
      | x == N = [head(testCase(xs))+1]
      | otherwise = testCase(xs)
  </code></pre>
  
  <p>The problem is in the function <code>projH</code>, I'm obviously missing a pattern, but I do handle the case with <code>[[],...]</code> with the <code>testCase</code> function and the <code>[[]]</code> case. I don't know why it throws me this error: </p>
  
  <pre><code>*Main&gt; projH g0
  [1,2,6,3,3,3*** Exception: devoir.hs:(17,1)-(18,39): Non-exhaustive patterns in function projH
  </code></pre>