[Haskell-cafe] Name that function =)

Stefan O'Rear stefanor at cox.net
Tue Dec 12 18:23:38 EST 2006


On Tue, Dec 12, 2006 at 11:29:11AM -0500, Louis J Scoras wrote:
> Which didn't work.  I thought about it a little more before realizing
> that putDirs wouldn't get any parameters this way: I needed some way
> to distribute the pair over both operations.  Here's the higher-order
> function I needed:
> 
>    foo h f g i = h (f i) (g i)

foo is a special case of Control.Monad.liftM2.

> import Control.Monad
> import Control.Monad.liftM2
> mapM_ (liftM2 (>>) print print) [2,3,4,5]
2
2
3
3
4
4
5
5

(This is using the Monad ((->) a) instance)

HTH, Stefan


More information about the Haskell-Cafe mailing list