On Tue, May 31, 2011 at 2:08 AM, Edward Kmett <span dir="ltr">&lt;<a href="mailto:ekmett@gmail.com">ekmett@gmail.com</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;">
<div><div></div><div class="h5">On Mon, May 23, 2011 at 5:13 AM, John Lato <span dir="ltr">&lt;<a href="mailto:jwlato@gmail.com" target="_blank">jwlato@gmail.com</a>&gt;</span> wrote:<br></div></div><div class="gmail_quote">
<div><div></div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Message: 3<br>
Date: Sun, 22 May 2011 06:52:49 -0400<br>
From: &quot;Edward Z. Yang&quot; &lt;<a href="mailto:ezyang@MIT.EDU" target="_blank">ezyang@MIT.EDU</a>&gt;<br>
Subject: Re: Proposal: Value strict versions of containers<br>
To: Milan Straka &lt;<a href="mailto:fox@ucw.cz" target="_blank">fox@ucw.cz</a>&gt;<br>
Cc: libraries &lt;<a href="mailto:libraries@haskell.org" target="_blank">libraries@haskell.org</a>&gt;<br>
Message-ID: &lt;1306061483-sup-1713@ezyang&gt;<br>
Content-Type: text/plain; charset=UTF-8<br>
<br>
Excerpts from Milan Straka&#39;s message of Sun May 22 06:50:07 -0400 2011:<br>
&gt; - the types Data.IntMap.IntMap, Data.IntMap.Lazy.IntMap and<br>
&gt;   Data.IntMap.Strict.IntMap should be equal -- so I can use strict<br>
&gt;   methods on IntMap someone else created with lazy methods. That is<br>
&gt;   simple in absence of type classes.<br>
<br>
Comment: This would mean you would get no static assurances against<br>
mixing up a strict IntMap with a lazy IntMap; for all intents and purposes,<br>
this is equivalent to implementing strict versions of all functions on top<br>
of a lazy data type.<br></blockquote><div><br></div><div>Another consequence to this design is that, should someone want to have</div><div><br></div><div>&gt; class MapC m key value | m -&gt; key, m -&gt; value where</div>


<div><br></div><div>it becomes impossible to directly write</div><div><br></div><div>&gt; instance MapC (Data.IntMap.Strict.IntMap Int a) Int a where</div><div>&gt;</div><div>&gt; instance MapC (Data.IntMap.Lazy.IntMap Int a) Int a where</div>


<div><br></div><div>because the two instances are the same.</div><div><br></div><div>Regardless, +1 for Milan&#39;s proposal either with one type or separate types for strict and lazy.</div></div></blockquote><div><br></div>

</div></div><div>I&#39;m perfectly fine with adding a separate module that exports the strict versions of the functions.</div><div><br></div><div>The main problem with the separate versions is that a strict value container is a valid instance of almost no interesting classes.</div>

<div><br></div><div>It violates the Functor laws, the Foldable laws, and Traversable laws, because of its treatment of bottoms. I would be +1 for the single type version, but I would have serious misgivings about a version with two types as the temptation to add those bogus instances would be strong.</div>
</div></blockquote><div><br></div><div>Programmers using strict containers need to make their own proofs for bottom anyway, so I don&#39;t see it as particularly onerous to do so for these instances provided that they&#39;re correct for non-bottom values and that it&#39;s documented.  With a strict container, I&#39;d rather have a Functor that doesn&#39;t handle bottoms properly than no Functor at all.</div>
<div><br></div><div>And with a single Map with strict and lazy interfaces, then wouldn&#39;t there properly be no strict Functor at all?  If the base map is strict, then the Functor instance would have to go through boxed values to handle bottom properly.  If the base map is lazy, the Functor instance would be lazy too, which would negate the benefits of a strict interface.  Is this correct?</div>
<div><br></div><div>John Lato</div></div>