Bringing the IntMap API up to par with the Map API

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Sat Aug 7 02:34:47 EDT 2010


Johan Tibell <johan.tibell at gmail.com> writes:

> On Fri, Aug 6, 2010 at 4:46 PM, Stephan Friedrichs <deduktionstheorem at web.de
>> wrote:
>
>> On 06/08/10 15:59, Johan Tibell wrote:
>> > There are a few functions on Maps that could be implemented on IntMaps
>> > but aren't: [...]
>>
>> Isn't it time to seriously think about defining maps as a type family to
>> avoid this sort of incompatibility once and for all and to enable GHC to
>> automatically use IntMap wherever appropriate?
>>
>> class Map k where
>>    data Map k :: * -> *
>>    empty ...
>>    insert ...
>>
>> instance Map Int where
>>    data Map Int v = Data.IntMap.IntMap v
>>    ...
>>
>> instance (Ord k) => Map k where
>>   data Map k v = Data.Map.Map k v
>>   ...
>>
>> Or something similar?
>>
>
> Definitely worth researching. I think we should pursue this as a separate
> track and fix what we have in the mean time.

I was going to be doing something like this as part of container-classes
(but in such a way that even [(a,b)] would be valid).

-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
IvanMiljenovic.wordpress.com


More information about the Libraries mailing list