[Haskell-cafe] Another point-free question (>>=, join, ap)

Thomas Davie tom.davie at gmail.com
Fri Feb 13 11:21:50 EST 2009


> 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

Bob


More information about the Haskell-Cafe mailing list