[Haskell-cafe] Data.Map - visiting tree nodes withi a given key range ?

Olaf Klinke olf at aatal-apotheke.de
Sun Mar 15 19:46:30 UTC 2020

By the way, there are tools to retrieve a certain range from compressed data, which IMHO is a very cool feature of gzip.


Bioinformaticians use it (among other things) for fast retrieval of genomic annotation from data sets with on the order of 10^9 keys (in case of human genome). Would be nice if someone wrote a Haskell binding. 


> Hello,
> I have a question regarding 'Data.Map' api, filed an issue 
> https://github.com/haskell/containers/issues/708
> And may be I can ask here at the same time?
> I'm not sure why|Data.Map|doesn't have a key range based visiting API, I 
> figured out I can do it this way:
> |indexKeyRange :: IndexKey -> IndexKey -> Map IndexKey Object -> 
> [(IndexKey, Object)] indexKeyRange !minKey !maxKey = toList . 
> takeWhileAntitone (<= maxKey) . dropWhileAntitone (< minKey) |
> But wouldn't it save the computation needed to re-balance the 
> intermediate tree generated ? Or that re-balancing can be optimized out 
> actually ?
> I am creating an in-memory graph database, using|Data.Map.Strict.Map|as 
> business object indices with specified object attributes. The typical 
> scenario will be querying a small number of entries by key range, out of 
> possibly all business objects of a certain class globally, so the 
> implementation above would work, but not reasonable by far as it seems.
> I think a lazy list returned by mere node visiting (i.e. no new node 
> creation) would satisfy my needs, or I missed something ?
> Thanks,
> Compl

More information about the Haskell-Cafe mailing list