On Fri, Feb 13, 2009 at 05:21:50PM +0100, Thomas Davie wrote: > > >Hey, > > > >Thanks for all the suggestions. I was hoping that there was some > >uniform > >pattern that would extend to n arguments (rather than having to use > >liftM2, litM3, etc. or have different 'application' operators in > >between > >the different arguments); perhaps not. Oh well :) > > Sure you can! What you want is Control.Applicative, not Control.Monad. > > (<*>) is the generic application you're looking for: > > > pure (+) <*> [1,2,3] <*> [4,5,6] > [5,6,7,6,7,8,7,8,9] > > Note that pure f <*> y can be shortened to fmap though, which > Control.Applicative defines a handy infix version of: > > (+) <$> [1,2,3] <*> [4,5,6] > [5,6,7,6,7,8,7,8,9] > > Hope that provides what you want
Hi Bob, Thanks for the suggestion, but that solution does not work when the function I want to apply (in your case, +) is monadic itself. Then I'd still have to write join $ f <*> [1,2,3] <*> [4,5,6] :( Edsko _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe