title: How to foldl an io operation on a list generated by a zip in order to print 2 columns?
body: <p>I have seen several questions regard to use of foldl and IO but none of them seem to provide a solution to my case.</p>
  <p>I am simply trying to output two columns of numbers.</p>
  <pre><code>0 256
  1 256
  2 256
  ...
  256 256
  0 255
  1 255
  2 255
  3 255
  4 255
  </code></pre>
  <p>I have tried the following but I was only able to print a single line and not an entire column:</p>
  <pre class="lang-hs prettyprint-override"><code>zipMerge :: [a] -&gt; [b] -&gt; [(a,b)]
  zipMerge [] _      = []
  zipMerge _  []     = error &quot;second list cannot be empty&quot;
  zipMerge (a:as) bs = (zip (replicate (length bs) a) bs) ++ (zipMerge as bs)
  
  -- foldl :: (a -&gt; b -&gt; a) -&gt; a -&gt; [b] -&gt; a
  printPixel :: IO() -&gt; (Int, Int) -&gt; IO()
  printPixel _ (i, j) = putStrLn (show i) ++ &quot; &quot; ++ (show j)
  
  printPixels :: [(Int, Int)] -&gt; IO()
  printPixels colors = foldl printPixel (return ()) colors
  
  printGradient :: IO()
  printGradient = do
      putStrLn &quot;255&quot;
      let is = [0..256]
          js = [256,255..0]
      printPixels (zipMerge js is)
  </code></pre>
  <p>What am I doing wrong ?</p>