title: Non Exhaustive Patterns in function
body: <p>I'm writing a program in Haskell that can pretty print a table and do basic queries on it. The following function is a snippet of the code which prints a table:</p>
  
  <pre><code>printTable :: Table -&gt; [String]
  printTable table@(header:rows) = [addLine] ++ addHeader ++ [addLine] ++ addRows rows ++ [addLine]
      where widthList            = columnWidths table
        makeTupleList []         = []
        makeTupleList (x:xs)     = zip widthList x : makeTupleList (xs)
        addRows line             = map printRow (makeTupleList line)
        addLine                  = printLine widthList
        addHeader                = addRows [(map.map) toUpper header]
  </code></pre>
  
  <p>Note: <code>Table == [[String]]</code></p>
  
  <p>After calling this function with the 'unlines' function, the table is printed.</p>
  
  <p>If I test this function, giving it a <code>[[String]]</code> argument, it works correctly. However, if I test this function in my 'main' code, I get the error:</p>
  
  <pre><code>Non-exhaustive patterns in function printTable
  </code></pre>
  
  <p>The only difference is that in my main code, the user of the program can give a text file as an input:</p>
  
  <pre><code>main :: IO()
  main = interact (lines &gt;&gt;&gt; exercise &gt;&gt;&gt; unlines)
  
  exercise :: [String] -&gt; [String]
  exercise = parseTable &gt;&gt;&gt; select "gender" "male" 
                    &gt;&gt;&gt; project ["last", "first", "salary"] &gt;&gt;&gt; printTable
  </code></pre>
  
  <p>Any help to solve this problem is more than welcome!</p>