<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">A lot of stuff to get one's head around. Was aware of liftM2, liftM3, etc., but not liftA2, liftA3, etc.<br><br>So, the statement was true, but not the way that was shown in the example, i.e., with fmap2, fmap3, etc., which required different functions for each of the fmaps.<br><br>Thanks. Appreciate the patience.<br><br>Michael<br><br>--- On <b>Thu, 8/26/10, Thomas Davie <i><tom.davie@gmail.com></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Thomas Davie <tom.davie@gmail.com><br>Subject: Re: [Haskell-cafe] On to applicative<br>To: "michael rice" <nowgate@yahoo.com><br>Cc: "Ivan Lazar Miljenovic" <ivan.miljenovic@gmail.com>, haskell-cafe@haskell.org<br>Date: Thursday, August 26, 2010, 3:10 AM<br><br><div id="yiv1793239067"><br><div><div>On 26 Aug 2010, at
08:01, michael rice wrote:</div><br class="yiv1793239067Apple-interchange-newline"><blockquote type="cite"><table style="" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font: inherit;" valign="top">Hmm... it was my understanding that the example was showing how to *avoid* having to create a lot of functions that do the same thing but have different numbers of arguments.<br><br>From the Wiki page:<br><br>"Anytime you feel the need to define different higher order functions to
accommodate for function-arguments with a different number of arguments,
think about how defining a proper instance of <code>Applicative</code> can make your life easier."<br><br>Not so?<br><br><br></td></tr></tbody></table></blockquote>Very much so – instead of defining liftA2, liftA3 etc like this, just use pure to get things into the applicative, and write <*> instead of ' ' to apply applicatives and you're done.</div><div><br></div><div>Don't write</div><div>liftA3 sumsq (Just 3) (Just 4) (Just 5)</div><div><br></div><div>Write</div><div>(pure sumsq) <*> (pure 3) <*> (pure 4) <*> (pure 5)</div><div><br></div><div>or you can get rid of that first pure with a quick fmap:</div><div>sumsq <$> (pure 3) <*> (pure 4) <*> (pure 5)</div><div><br></div><div>Bob</div></div></blockquote></td></tr></table><br>