Hi Louis,<br><br>Try foo = liftM2, and check out the recent haskell thread "Cannot understand liftM2". <br><br>Cheers, - Conal<br><br><div><span class="gmail_quote">On 12/12/06, <b class="gmail_sendername">Louis J Scoras
</b> <<a href="mailto:louis.j.scoras@gmail.com">louis.j.scoras@gmail.com</a>> 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. It
<br>wasn't difficult to actually get the right behavior by just doing mapM<br>twice.<br><br> -- putDirs just outputs something like "mv fst snd"<br> mapM_ putDirs pairs<br> mapM_ (uncurry renameFile) pairs
<br><br>This bothered me though, because I suspected that this could be done<br>in one pass. Naively I proceeded to this.<br><br> mapM_ (putDirs >> (uncurry renameFile)) pairs<br><br>Which didn't work. 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. Here's the higher-order<br>function I needed:<br><br> foo h f g i = h (f i) (g i)<br><br>which could then be curried and we get:
<br><br> mapM_ (foo (>>) putDirs $ uncurry renameFile) pairs<br><br>Works great. So my question: is there a established name for foo?<br>What about foo partially applied to (>>)? 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>