title: Applying tuple of functions to a tuple
body: <p>I'm trying to apply a tuple of functions to a tuple of values</p>
  
  <pre><code>λ&gt; let foo = ((+1), (*3), ((:)5))  #Each function has type: a -&gt; a
  
  λ&gt; let bar  = (1, 5, [0])          #Each value of the corresponding tuple has type a
  </code></pre>
  
  <p>How do I implement: </p>
  
  <pre><code>toImplement foo bar = ?
  </code></pre>
  
  <p>such that:</p>
  
  <pre><code>λ&gt; toImplement foo bar
  -&gt; (2, 15, [0,5]) # using foo and bar above
  </code></pre>
  
  <p>How can you implement this in general for any valid foo and bar (of the same length)?</p>
  
  <p>[I looked at <a href="https://stackoverflow.com/questions/26092198/haskell-apply-tuple-of-functions-to-tuple-of-values">this problem</a>, but it is implemented for a fixed type. I require a general implementation]</p>
  
  <p>Motivation:</p>
  
  <p>I'm trying to write folds efficiently. </p>
  
  <pre><code>let acc1 = \x acc -&gt; x*x:acc
  let acc2 = (+)
  foldr (\x acc -&gt; (acc1 x (fst acc), acc2 x ( snd acc))) ([],0) [1..10]
  &gt; ([1,4,9,16,25,36,49,64,81,100],55)
  </code></pre>
  
  <p>I have 2 different accumulators acc1 &amp; acc2 that loop over the list exactly once. I'd like to do this for arbitrary number of accumulators all of whom have type a -> b [where a is the type of the elements in the list and b is of the type of the output of the accumulator]
  It looks clumsy, having to access the tuples using fst and snd :/</p>