instance Applicative Data.Map

Conal Elliott conal at conal.net
Wed Nov 14 23:01:04 CET 2012


For more about motivation & design of TMap and its relationship to Map, see
*Denotational design with type class
morphisms*<http://conal.net/papers/type-class-morphisms/>.
-- Conal

On Wed, Nov 14, 2012 at 1:07 PM, Jake McArthur <jake.mcarthur at gmail.com>wrote:

> 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
> this:
>
>     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 gmail.com>wrote:
>
>> Sorry for the double send, Henning. I forgot the list.
>>
>>
>> http://hackage.haskell.org/packages/archive/total-map/0.0.4/doc/html/Data-TotalMap.html
>>
>>
>> On Wed, Nov 14, 2012 at 2:46 PM, Henning Thielemann <
>> lemming at henning-thielemann.de> 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 haskell.org
>>> http://www.haskell.org/**mailman/listinfo/libraries<http://www.haskell.org/mailman/listinfo/libraries>
>>>
>>
>>
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20121114/14aa8117/attachment.htm>


More information about the Libraries mailing list