instance Applicative Data.Map

Jake McArthur jake.mcarthur at
Wed Nov 14 22:07:55 CET 2012

Now I'm just spamming, but I feel I should elaborate more.

A slight superset of the original semantics of Map can be recovered like

    type Map k v = TMap k (Maybe v)

So, nothing is really lost, apart from the specific library I linked not
being very rich. Your example having intersection semantics would be
written like this:

    (liftA3.liftA3) f amap bmap cmap

In fact, even this restricted form of TMap is still a monad (having the
same semantics as ReaderT k Maybe v). Come to think of it, there should be
a monad transformer version of TMap.

- Jake

On Wed, Nov 14, 2012 at 3:50 PM, Jake McArthur <jake.mcarthur at>wrote:

> Sorry for the double send, Henning. I forgot the list.
> On Wed, Nov 14, 2012 at 2:46 PM, Henning Thielemann <
> lemming at> wrote:
>> An ZipList-like Applicative instance for Data.Map would be nice. I have
>> an application where I like to write
>>    liftA3 f amap bmap cmap
>>  meaning
>>    Map.intersectionWith ($) (Map.intersectionWith f amap bmap) cmap
>> But I cannot complete the instance implementation because there is no
>> sensible definition for 'pure' for Data.Map. :-(
>> ______________________________**_________________
>> Libraries mailing list
>> Libraries at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Libraries mailing list