Discussion: Add unboxed mutable references somewhere sensible

Michael Snoyman michael at snoyman.com
Thu Feb 12 03:35:46 UTC 2015


I added this to mutable-containers. It's easiest to see this by looking at
three readme on

http://www.stackage.org/package/mutable-containers

I'd support something like this in primitive as well.

On Thu, Feb 12, 2015, 4:36 AM Dan Doel <dan.doel at gmail.com> wrote:

> We could add something like this to primitive. It has a generalization of
> things like STRef, under the name MutVar.
>
> On Wed, Feb 11, 2015 at 7:03 PM, David Feuer <david.feuer at gmail.com>
> wrote:
>
>> The problem they solve is perhaps not as well known as it should be:
>>
>> Code that frequently modifies an `STRef Int`, for example, will
>> typically surprise the programmer by allocating a ton of memory. This
>> happens because the reference holds a *boxed* Int. Code like
>>
>>     modifySTRef ref (+1)
>>
>> will allocate a new Int box every time. To the best of my knowledge,
>> GHC makes no attempt to figure out if this is actually necessary and
>> do something about it. The Data.Ref.Unboxed module in the ArrayRef
>> package attempts to address this, but it doesn't seem to get much
>> visibility, and its code hasn't been touched since 2009. What can we
>> do about this?
>> _______________________________________________
>> Libraries mailing list
>> Libraries at haskell.org
>> http://www.haskell.org/mailman/listinfo/libraries
>>
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20150212/0111446f/attachment.html>


More information about the Libraries mailing list