<p dir="ltr">I added this to mutable-containers. It's easiest to see this by looking at three readme on</p>
<p dir="ltr"><a href="http://www.stackage.org/package/mutable-containers">http://www.stackage.org/package/mutable-containers</a></p>
<p dir="ltr">I'd support something like this in primitive as well.</p>
<br><div class="gmail_quote">On Thu, Feb 12, 2015, 4:36 AM Dan Doel <<a href="mailto:dan.doel@gmail.com">dan.doel@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">We could add something like this to primitive. It has a generalization of things like STRef, under the name MutVar.<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 11, 2015 at 7:03 PM, David Feuer <span dir="ltr"><<a href="mailto:david.feuer@gmail.com" target="_blank">david.feuer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The problem they solve is perhaps not as well known as it should be:<br>
<br>
Code that frequently modifies an `STRef Int`, for example, will<br>
typically surprise the programmer by allocating a ton of memory. This<br>
happens because the reference holds a *boxed* Int. Code like<br>
<br>
    modifySTRef ref (+1)<br>
<br>
will allocate a new Int box every time. To the best of my knowledge,<br>
GHC makes no attempt to figure out if this is actually necessary and<br>
do something about it. The Data.Ref.Unboxed module in the ArrayRef<br>
package attempts to address this, but it doesn't seem to get much<br>
visibility, and its code hasn't been touched since 2009. What can we<br>
do about this?<br>
_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/mailman/listinfo/libraries</a><br>
</blockquote></div><br></div>
______________________________<u></u>_________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/<u></u>mailman/listinfo/libraries</a><br>
</blockquote></div>