title: Employing arrows to fold a list of tuples
body: <p>Sometimes you want to fold a list of tuples into one tuple using different folding functions. For instance, in order to glue together a list of runState results, getting an (in some sense) combined state and a combined result.</p>
  
  <p>Consider the following implementation:</p>
  
  <pre><code>wish :: (a -&gt; a' -&gt; a) -&gt; (b -&gt; b' -&gt; b) -&gt; (a,b) -&gt; [(a', b')] -&gt; (a,b)
  wish lfn rfn x xs = foldl (\(a,b) -&gt; (lfn a) *** (rfn b)) x xs
  </code></pre>
  
  <p>Although it works, I feel uncomfortable about this lambda. <code>lfn *** rfn</code> by itself has a type of <code>(a,b) -&gt; (a -&gt; a', b -&gt; b')</code>, which I can't find a way to properly apply to a tuple without ever resorting to pattern matching. Is there a clear and elegant way I'm missing? It could be a library function of type <code>(a,a') -&gt; (a -&gt; a, a' -&gt; a') -&gt; (a, a')</code> or a whole different approach, maybe.</p>