On Thu, Oct 27, 2011 at 10:03 AM, Edward Z. Yang <span dir="ltr">&lt;<a href="mailto:ezyang@mit.edu">ezyang@mit.edu</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

I&#39;d like to remark that the situation with keys is not /quite/ comparable.<br>
Even if we don&#39;t need to look at the key for inserting into an empty map,<br>
it will get forced anyway because IntMaps are spine-strict (in particular, they<br>
are strict in their keys.)</blockquote><div class="gmail_quote"><br></div><div class="gmail_quote">I&#39;m not quite sure if I follow. Here&#39;s Data.IntMap.insert:</div><br>    insert :: Key -&gt; a -&gt; IntMap a -&gt; IntMap a<br>

    insert k x t = k `seq`<br>      case t of<br>        Bin p m l r<br>          | nomatch k p m -&gt; join k (Tip k x) p t<br>          | zero k m      -&gt; Bin p m (insert k x l) r<br>          | otherwise     -&gt; Bin p m l (insert k x r)<br>

        Tip ky _<br>          | k==ky         -&gt; Tip k x<br>          | otherwise     -&gt; join k (Tip k x) ky t<br>        Nil -&gt; Tip k x</div><div class="gmail_quote"><br></div><div class="gmail_quote">Without the explicit `seq`</div>

<div class="gmail_quote"><br></div><div class="gmail_quote">    insert undefined 1 Nil</div><div class="gmail_quote"><br></div><div class="gmail_quote">terminates but with the `seq` it&#39;s _|_.</div><div class="gmail_quote">

<br></div><div class="gmail_quote">Are you saying it will eventually get force if someone e.g. does a lookup after the insert?</div><div class="gmail_quote"><br><div>-- Johan</div><div> </div></div>