
Hey folks, I understand most of what is going on with the applicative class, but I can't figure out why this instance is useful: "instance Applicative ((->) a) where..." Can anyone offer some intuition into how this is could be used? Ian Duncan

Here are a couple of examples
(+) <$> Just 7 <*> Just 8 Just 15
(*) <$> [1, 2, 3] <*> [4, 5, 6] [4,5,6,8,10,12,12,15,18]
Ian Duncan wrote:
Hey folks, I understand most of what is going on with the applicative class, but I can't figure out why this instance is useful: "instance Applicative ((->) a) where..."
Can anyone offer some intuition into how this is could be used?
Ian Duncan
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
-- Tony Morris http://tmorris.net/

Woops sorry, try again.
let f = (+) <$> (+1) <*> (*7) in f 2 17
Consider: \f g a -> f a `k` g a can be rewritten: liftA2 k Thomas Davie wrote:
On 11 Jul 2009, at 13:54, Tony Morris wrote:
Here are a couple of examples
(+) <$> Just 7 <*> Just 8 Just 15
(*) <$> [1, 2, 3] <*> [4, 5, 6] [4,5,6,8,10,12,12,15,18]
Those are for Maybe and [] respectively though, not ((->) a)
Bob
-- Tony Morris http://tmorris.net/

Ian Duncan wrote:
Hey folks, I understand most of what is going on with the applicative class, but I can't figure out why this instance is useful: "instance Applicative ((->) a) where..."
Can anyone offer some intuition into how this is could be used?
As hinted to in the paper on applicative functors, Applicative programming with effects Conor McBride, Ross Paterson. http://strictlypositive.org/IdiomLite.pdf the instance functors are the S and K combinators. http://en.wikipedia.org/wiki/SKI_combinator_calculus Regards, apfelmus -- http://apfelmus.nfshost.com
participants (4)
-
Heinrich Apfelmus
-
Ian Duncan
-
Thomas Davie
-
Tony Morris