Applicative ((,) a)

Stefan O'Rear 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
> Effects<http://www.soi.city.ac.uk/%7Eross/papers/Applicative.html>"?
> I didn't spot  a mention.

That's the Applicative instance corresponding to the "writer" monad.

(messages, value)

(["foo"], (*2)) <*> (["bar"], 2)  ==>  (["foo", "bar"], 4)

Stefan


More information about the Libraries mailing list