<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hmm... it was my understanding that the example was showing how to *avoid* having to create a&nbsp; 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>Michael<br><br><br><br>--- On <b>Thu, 8/26/10, Ivan Lazar Miljenovic <i>&lt;ivan.miljenovic@gmail.com&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Ivan Lazar Miljenovic &lt;ivan.miljenovic@gmail.com&gt;<br>Subject: Re: [Haskell-cafe] On to applicative<br>To: "michael rice" &lt;nowgate@yahoo.com&gt;<br>Cc: haskell-cafe@haskell.org<br>Date: Thursday, August 26, 2010, 2:50 AM<br><br><div class="plainMail">On 26 August 2010 16:47, michael rice &lt;<a ymailto="mailto:nowgate@yahoo.com" href="/mc/compose?to=nowgate@yahoo.com">nowgate@yahoo.com</a>&gt; wrote:<br>&gt;<br>&gt; OK, fmap2 works, but not fmap3. What am I not understanding?<br>&gt;<br>&gt; Michael<br>&gt;<br>&gt; import Control.Applicative<br>&gt;<br>&gt; -- f :: (a -&gt; b -&gt; c)<br>&gt; --
 fmap :: Functor f =&gt; (d -&gt; e) -&gt; f d -&gt; f e<br>&gt;<br>&gt; sumsqr :: Int -&gt; Int -&gt; Int<br>&gt; sumsqr i j = i*i+j*j<br>&gt;<br>&gt; -- fmap :: Functor f =&gt; f a -&gt; f (b -&gt; c)&nbsp;&nbsp;&nbsp; -- Identify d with a, and e with (b -&gt; c)<br>&gt;<br>&gt;<br>&gt; fmap2 f a b = f `fmap` a &lt;*&gt; b<br>&gt; fmap3 f a b c = f `fmap` a &lt;*&gt; b &lt;*&gt; c<br>&gt; fmap4 f a b c d = f `fmap` a &lt;*&gt; b &lt;*&gt; c &lt;*&gt; d<br>&gt;<br>&gt;<br>&gt; -- fmap2 f a b = f &lt;$&gt; a &lt;*&gt; b<br>&gt; -- fmap3 f a b c = f &lt;$&gt; a &lt;*&gt; b &lt;*&gt; c<br>&gt; -- fmap4 f a b c d = f &lt;$&gt; a &lt;*&gt; b &lt;*&gt; c &lt;*&gt; d<br>&gt;<br>&gt;<br>&gt; *Main&gt; fmap2 sumsqr (Just 3) (Just 4)<br>&gt; Just 25<br>&gt; *Main&gt; fmap3 sumsqr (Just 3) (Just 4) (Just 5)<br>&gt;<br>&gt; &lt;interactive&gt;:1:6:<br>&gt; &nbsp;&nbsp;&nbsp; Couldn't match expected type `a2 -&gt; b' against inferred type `Int'<br>&gt;
 &nbsp;&nbsp;&nbsp; In the first argument of `fmap3', namely `sumsqr'<br>&gt; &nbsp;&nbsp;&nbsp; In the expression: fmap3 sumsqr (Just 3) (Just 4) (Just 5)<br>&gt; &nbsp;&nbsp;&nbsp; In the definition of `it':<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; it = fmap3 sumsqr (Just 3) (Just 4) (Just 5)<br>&gt; *Main&gt;<br><br>sumsqr takes three arguments; fmap3 has type:<br><br>fmap3 :: (a -&gt; b -&gt; c -&gt; d) -&gt; Maybe a -&gt; Maybe b -&gt; Maybe c -&gt; Maybe d<br><br>i.e. the function you pass it needs to take 3 arguments.<br><br>fmap3 (\ x y z -&gt; z * y + z) (Just 1) (Just 2) (Just 3)<br><br>&gt;<br>&gt;<br>&gt; --- On Thu, 8/26/10, Ivan Lazar Miljenovic &lt;<a ymailto="mailto:ivan.miljenovic@gmail.com" href="/mc/compose?to=ivan.miljenovic@gmail.com">ivan.miljenovic@gmail.com</a>&gt; wrote:<br>&gt;<br>&gt; From: Ivan Lazar Miljenovic &lt;<a ymailto="mailto:ivan.miljenovic@gmail.com"
 href="/mc/compose?to=ivan.miljenovic@gmail.com">ivan.miljenovic@gmail.com</a>&gt;<br>&gt; Subject: Re: [Haskell-cafe] On to applicative<br>&gt; To: "michael rice" &lt;<a ymailto="mailto:nowgate@yahoo.com" href="/mc/compose?to=nowgate@yahoo.com">nowgate@yahoo.com</a>&gt;<br>&gt; Cc: <a ymailto="mailto:haskell-cafe@haskell.org" href="/mc/compose?to=haskell-cafe@haskell.org">haskell-cafe@haskell.org</a><br>&gt; Date: Thursday, August 26, 2010, 2:33 AM<br>&gt;<br>&gt; On 26 August 2010 16:29, michael rice &lt;<a ymailto="mailto:nowgate@yahoo.com" href="/mc/compose?to=nowgate@yahoo.com">nowgate@yahoo.com</a>&gt; wrote:<br>&gt; &gt;<br>&gt; &gt; Can you recommend an example that works?<br>&gt;<br>&gt; An example of what?<br>&gt;<br>&gt; The definitions of fmap2, etc. on that page look like they're correct.<br>&gt;<br>&gt; --<br>&gt; Ivan Lazar Miljenovic<br>&gt; <a ymailto="mailto:Ivan.Miljenovic@gmail.com"
 href="/mc/compose?to=Ivan.Miljenovic@gmail.com">Ivan.Miljenovic@gmail.com</a><br>&gt; IvanMiljenovic.wordpress.com<br>&gt;<br><br><br><br>--<br>Ivan Lazar Miljenovic<br><a ymailto="mailto:Ivan.Miljenovic@gmail.com" href="/mc/compose?to=Ivan.Miljenovic@gmail.com">Ivan.Miljenovic@gmail.com</a><br>IvanMiljenovic.wordpress.com<br></div></blockquote></td></tr></table><br>