Applicative ((,) a)
stefanor at cox.net
Fri Mar 9 20:27:30 EST 2007
On Fri, Mar 09, 2007 at 05:23:06PM -0800, Conal Elliott wrote:
> What was the motivation for providing the following Applicative instance?
> instance Monoid a => Applicative ((,) a) where
> pure x = (mempty, x)
> (u, f) <*> (v, x) = (u `mappend` v, f x)
> Is this instance described in "Applicative Programming with
> I didn't spot a mention.
That's the Applicative instance corresponding to the "writer" monad.
(["foo"], (*2)) <*> (["bar"], 2) ==> (["foo", "bar"], 4)
More information about the Libraries