<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hello,</p>
<p>I have a question regarding 'Data.Map' api, filed an issue <a
href="https://github.com/haskell/containers/issues/708">https://github.com/haskell/containers/issues/708</a></p>
<p>And may be I can ask here at the same time?</p>
<p style="box-sizing: border-box; margin-top: 0px !important;
margin-bottom: 16px; color: rgb(36, 41, 46); font-family:
-apple-system, BlinkMacSystemFont, "Segoe UI",
Helvetica, Arial, sans-serif, "Apple Color Emoji",
"Segoe UI Emoji"; font-size: 14px; font-style: normal;
font-variant-ligatures: normal; font-variant-caps: normal;
font-weight: 400; letter-spacing: normal; orphans: 2; text-align:
start; text-indent: 0px; text-transform: none; white-space:
normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width:
0px; background-color: rgb(255, 255, 255); text-decoration-style:
initial; text-decoration-color: initial;">I'm not sure why<span> </span><code
style="box-sizing: border-box; font-family: SFMono-Regular,
Consolas, "Liberation Mono", Menlo, monospace;
font-size: 11.9px; padding: 0.2em 0.4em; margin: 0px;
background-color: rgba(27, 31, 35, 0.05); border-radius: 3px;">Data.Map</code><span> </span>doesn't
have a key range based visiting API, I figured out I can do it
this way:</p>
<pre style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 11.9px; margin-top: 0px; margin-bottom: 16px; overflow-wrap: normal; padding: 16px; overflow: auto; line-height: 1.45; background-color: rgb(246, 248, 250); border-radius: 3px; color: rgb(36, 41, 46); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"><code style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 11.9px; padding: 0px; margin: 0px; background: initial; border-radius: 3px; word-break: normal; white-space: pre; border: 0px; display: inline; overflow: visible; line-height: inherit; overflow-wrap: normal;">indexKeyRange
:: IndexKey -> IndexKey -> Map IndexKey Object -> [(IndexKey, Object)]
indexKeyRange !minKey !maxKey =
toList
. takeWhileAntitone (<= maxKey)
. dropWhileAntitone (< minKey)
</code></pre>
<p style="box-sizing: border-box; margin-top: 0px; margin-bottom:
16px; color: rgb(36, 41, 46); font-family: -apple-system,
BlinkMacSystemFont, "Segoe UI", Helvetica, Arial,
sans-serif, "Apple Color Emoji", "Segoe UI
Emoji"; font-size: 14px; font-style: normal;
font-variant-ligatures: normal; font-variant-caps: normal;
font-weight: 400; letter-spacing: normal; orphans: 2; text-align:
start; text-indent: 0px; text-transform: none; white-space:
normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width:
0px; background-color: rgb(255, 255, 255); text-decoration-style:
initial; text-decoration-color: initial;">But wouldn't it save the
computation needed to re-balance the intermediate tree generated ?
Or that re-balancing can be optimized out actually ?</p>
<p style="box-sizing: border-box; margin-top: 0px; margin-bottom:
16px; color: rgb(36, 41, 46); font-family: -apple-system,
BlinkMacSystemFont, "Segoe UI", Helvetica, Arial,
sans-serif, "Apple Color Emoji", "Segoe UI
Emoji"; font-size: 14px; font-style: normal;
font-variant-ligatures: normal; font-variant-caps: normal;
font-weight: 400; letter-spacing: normal; orphans: 2; text-align:
start; text-indent: 0px; text-transform: none; white-space:
normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width:
0px; background-color: rgb(255, 255, 255); text-decoration-style:
initial; text-decoration-color: initial;">I am creating an
in-memory graph database, using<span> </span><code
style="box-sizing: border-box; font-family: SFMono-Regular,
Consolas, "Liberation Mono", Menlo, monospace;
font-size: 11.9px; padding: 0.2em 0.4em; margin: 0px;
background-color: rgba(27, 31, 35, 0.05); border-radius: 3px;">Data.Map.Strict.Map</code><span> </span>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.</p>
<p style="box-sizing: border-box; margin-top: 0px; margin-bottom:
0px !important; color: rgb(36, 41, 46); font-family:
-apple-system, BlinkMacSystemFont, "Segoe UI",
Helvetica, Arial, sans-serif, "Apple Color Emoji",
"Segoe UI Emoji"; font-size: 14px; font-style: normal;
font-variant-ligatures: normal; font-variant-caps: normal;
font-weight: 400; letter-spacing: normal; orphans: 2; text-align:
start; text-indent: 0px; text-transform: none; white-space:
normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width:
0px; background-color: rgb(255, 255, 255); text-decoration-style:
initial; text-decoration-color: initial;">I think a lazy list
returned by mere node visiting (i.e. no new node creation) would
satisfy my needs, or I missed something ?</p>
<p style="box-sizing: border-box; margin-top: 0px; margin-bottom:
0px !important; color: rgb(36, 41, 46); font-family:
-apple-system, BlinkMacSystemFont, "Segoe UI",
Helvetica, Arial, sans-serif, "Apple Color Emoji",
"Segoe UI Emoji"; font-size: 14px; font-style: normal;
font-variant-ligatures: normal; font-variant-caps: normal;
font-weight: 400; letter-spacing: normal; orphans: 2; text-align:
start; text-indent: 0px; text-transform: none; white-space:
normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width:
0px; background-color: rgb(255, 255, 255); text-decoration-style:
initial; text-decoration-color: initial;"><br>
</p>
<p>Thanks,</p>
<p>Compl</p>
<p><br>
</p>
</body>
</html>