A lot of stuff to get one's head around. Was aware of liftM2, liftM3, etc., but 
not liftA2, liftA3, etc.

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.

Thanks. Appreciate the patience.

Michael

--- On Thu, 8/26/10, Thomas Davie <tom.da...@gmail.com> wrote:

From: Thomas Davie <tom.da...@gmail.com>
Subject: Re: [Haskell-cafe] On to applicative
To: "michael rice" <nowg...@yahoo.com>
Cc: "Ivan Lazar Miljenovic" <ivan.miljeno...@gmail.com>, 
haskell-cafe@haskell.org
Date: Thursday, August 26, 2010, 3:10 AM


On 26 Aug 2010, at 08:01, michael rice wrote:
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.

>From the Wiki page:

"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 Applicative can make your life 
easier."

Not so?


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.
Don't writeliftA3 sumsq (Just 3) (Just 4) (Just 5)
Write(pure sumsq) <*> (pure 3) <*> (pure 4) <*> (pure 5)
or you can get rid of that first pure with a quick fmap:sumsq <$> (pure 3) <*> 
(pure 4) <*> (pure 5)
Bob


      
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to