Efficent lens operation for Data.Map et al.

roconnor at theorem.ca roconnor at theorem.ca
Thu Jan 19 01:26:02 CET 2012

On Wed, 18 Jan 2012, Johan Tibell wrote:

> On Wed, Jan 18, 2012 at 1:51 PM, Roman Cheplyaka <roma at ro-che.info> wrote:
>> * roconnor at theorem.ca <roconnor at theorem.ca> [2012-01-18 16:35:52-0500]
>>> On Wed, 18 Jan 2012, Johan Tibell wrote:
>>>> IIRC you just replace the current functions with yours and run make in
>>>> the benchmarks/ directory to compile the benchmark binaries (which use
>>>> Criterion). Then simply run them.
>>> I got an error trying to build the benchmarks:
>> Worked for me with GHC 7.0.4.
>> The results are attached.
>> In short, your version is indeed typically slower, up to a factor of 5
>> (for lookup).
> That's even slower than I expected. Doesn't mean that we cannot add
> the operation though (although we should think about exactly which
> operation(s) we need.)

Ya, all I really want is one function:

lens :: Key -> IntMap a -> (Maybe a -> IntMap a, Maybe a)

for every container type.

Russell O'Connor                                      <http://r6.ca/>
``All talk about `theft,''' the general counsel of the American Graphophone
Company wrote, ``is the merest claptrap, for there exists no property in
ideas musical, literary or artistic, except as defined by statute.''

More information about the Libraries mailing list