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

Compl Yue compl.yue at icloud.com
Sun Mar 15 17:30:14 UTC 2020

Thanks Olaf,

Can you point me to the specific function for key range traversal? I 
went over the module doc for Data.Map.Internal and 
Data.Map.Strict.Internal twice, yet still don't get which one supposed 
to work for me, or I should ignore doc and look at the code instead ?

And the values to be scanned in specific key range are going to be 
consumed by some CPS mutual iterator, so fold can't be used as I see it.

Best regards,


On 2020/3/15 下午9:37, Olaf Klinke wrote:
> You can roll your own indexKeyRange using the Data.Map.Internal module which exposes the (currently used) Map implementation. Also note that if the list of values in range is to be consumed immediately, you might want to go for a fold-based function:
> foldlWithRange :: (a -> k -> b -> a) -> (a,a) -> b -> Map k a -> b
> Olaf

More information about the Haskell-Cafe mailing list