title: Haskell - "Non-exhaustive patterns" error with a function using list
body: <p>I'm trying to make a function in haskell to know if all the elements in a list of list have the same length. (I've search answers in previous posts but none of them works).</p>
  
  <pre><code>sameLength :: [[t]] -&gt; String
  sameLength [] = "Empty list"
  sameLength [[items]]
      | and $ map (\x -&gt; length x == (length $ head [[items]])) [[items]] = "Same length"
      | otherwise = "Not the same length"
  </code></pre>
  
  <p>The problem is that it doesn't work :</p>
  
  <pre><code>*Main&gt; :l test.hs
  [1 of 1] Compiling Main             ( test.hs, interpreted )
  Ok, modules loaded: Main.
  *Main&gt; sameLength []
  "Empty list"
  *Main&gt; sameLength [[1,2],[3,4]]
  "*** Exception: test.hs:(2,1)-(5,39): Non-exhaustive patterns in function sameLength
  
  *Main&gt; sameLength [[1,2]]
  "*** Exception: test.hs:(2,1)-(5,39): Non-exhaustive patterns in function sameLength
  </code></pre>
  
  <p>I don't really see where is the problem. It treat the case in which the parameter is an empty list and in which it is not. Am I wrong ? Did i miss something ?</p>
  
  <p>Thanks for your help :)</p>