On Thu, Feb 17, 2011 at 8:15 PM, Ivan Lazar Miljenovic <span dir="ltr">&lt;<a href="mailto:ivan.miljenovic@gmail.com">ivan.miljenovic@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 class="im">On 18 February 2011 11:51, Johan Tibell &lt;<a href="mailto:johan.tibell@gmail.com">johan.tibell@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; Option 1:<br>
&gt; Data.HashMap (strict)<br>
&gt; Data.HashMap.Lazy<br>
<br>
</div>This would probably work the best, especially as it&#39;s the behaviour<br>
already taken by ByteString, Text, etc.</blockquote><div><br></div><div>However, it is quite different than the behavior of Data.Map, which is a much closer analogue. Bytestring and Text&#39;s strict and lazy versions are radically different structures from one another. Here the miniscule differences between strict and lazy WriterT, StateT, etc. is probably a much closer analogue. There they use the separate data types to reflect the fact that you have different operations that you want classes to provide (like the strict map in the above discussion).</div>
<div><br></div><div>Here I&#39;d probably look more towards the mtl and transformers as a guideline, as it has been balancing tensions between the two world views with regards to maximizing laziness for a long time. That would steer towards Option 3, likely with being lazy in the value being the default exported from Data.HashMap.</div>
<div><br></div><div>But even that analogy is flawed, because there the only difference is the use of a few irrefutable patterns to avoid a couple of bottoms where possible. Here the difference in strictness is much more dramatic as it causes you to fail even the <b>Functor</b> laws and I for one would really like to see these be Foldable/Traversable, etc. </div>
<div><br></div><div>Making the map strict in the value (at least for map, traverse, mapM) is pretty ugly because it changes the set of things that it can contain by making it an error to try to stuff an error, undefined, or potentially bottom value into the map.</div>
<div><br></div><div>Making the map strict in its internal structure never introduces non-termination into your code, and is almost always a win because of the decreased amount of indirect jumps made by the STG. Making the map strict in the values shrinks the size of the range of the map unnaturally, and makes it veer radically from the model of a function from k -&gt; Maybe v.</div>
<div><br></div><div>-Edward Kmett</div><div><br></div></div>