title: How to return a list of tuples in Haskell
body: <p>I'm taking an optimization class in C++ and have been trying to recode the labs in Haskell for kicks and giggles.  The going has been rough but very interesting.  </p>
  
  <p>I'm trying to write a function that returns a list of 3 Integer tuples like so:</p>
  
  <p><code>[(1,1,1),(1,2,1),(1,3,2)]</code></p>
  
  <p>Here is the code I've been attempting to use:</p>
  
  <pre><code>sortToTuples :: (Num a) =&gt; [a] -&gt; Int -&gt; Int -&gt; [(Int,Int,a)]
  sortToTuples [] _ _ = []
  -- i and j are passed as 1 and 1.
  sortToTuples (x:xs) i j   
      | j &gt; 9         = [(i+1, 1, x)] ++ sortToTuples (xs i+1 1)
      | otherwise     = [(i, j+1, x)] ++ sortToTuples (xs i, j+1)
  </code></pre>
  
  <p>The function is meant to take a flat list that represents a sudoku puzzle and return a list of tuples (i,j,x) where i is the row value, j is the column value, and x is the value of the cell.</p>
  
  <p>For whatever reason haskell is very unhappy with my type signature:</p>
  
  <pre><code>Prelude&gt; :l quicksort.hs 
  [1 of 1] Compiling Main             ( quicksort.hs, interpreted )
  
  quicksort.hs:23:44:
      Couldn't match expected type `[(Int, Int, a)]'
                  with actual type `Int -&gt; Int -&gt; [(Int, Int, a0)]'
      In the return type of a call of `sortToTuples'
      Probable cause: `sortToTuples' is applied to too few arguments
      In the second argument of `(++)', namely
        `sortToTuples (xs i + 1 1)'
      In the expression: [(i + 1, 1, x)] ++ sortToTuples (xs i + 1 1)
  Failed, modules loaded: none.
  Prelude&gt; 
  </code></pre>