Hi Louis,<br><br>Try foo = liftM2, and check out the recent haskell thread &quot;Cannot understand liftM2&quot;.&nbsp; <br><br>Cheers, - Conal<br><br><div><span class="gmail_quote">On 12/12/06, <b class="gmail_sendername">Louis J Scoras
</b> &lt;<a href="mailto:louis.j.scoras@gmail.com">louis.j.scoras@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi all;<br><br>I'm new to the list, so I just wanted to say hi and -- of course --<br>ask a quick question:<br><br>I have some IO actions that I want to map over a list of pairs --<br>these are just directory names and their down-cased versions.&nbsp;&nbsp;It
<br>wasn't difficult to actually get the right behavior by just doing mapM<br>twice.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;-- putDirs just outputs something like &quot;mv fst snd&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;mapM_ putDirs pairs<br>&nbsp;&nbsp;&nbsp;&nbsp;mapM_ (uncurry renameFile) pairs
<br><br>This bothered me though, because I suspected that this could be done<br>in one pass.&nbsp;&nbsp;Naively I proceeded to this.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;mapM_ (putDirs &gt;&gt; (uncurry renameFile)) pairs<br><br>Which didn't work.&nbsp;&nbsp;I thought about it a little more before realizing
<br>that putDirs wouldn't get any parameters this way: I needed some way<br>to distribute the pair over both operations.&nbsp;&nbsp;Here's the higher-order<br>function I needed:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;foo h f g i = h (f i) (g i)<br><br>which could then be curried and we get:
<br><br>&nbsp;&nbsp;&nbsp;&nbsp;mapM_ (foo (&gt;&gt;) putDirs $ uncurry renameFile) pairs<br><br>Works great.&nbsp;&nbsp;So my question: is there a established name for foo?<br>What about foo partially applied to (&gt;&gt;)?&nbsp;&nbsp;This was a fun exercise,<br>
but I'd like to use the standard implementations if they exist.<br><br>Thanks!<br><br><br>--<br>Lou.<br>_______________________________________________<br>Haskell-Cafe mailing list<br><a href="mailto:Haskell-Cafe@haskell.org">
Haskell-Cafe@haskell.org</a><br><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br></blockquote></div><br>