AFAIUI wrapping in an IORef constructor then calling mkWeakIORef simply to add a finalizer should be fine.<br><br><div class="gmail_quote">On Tue Dec 02 2014 at 5:12:24 AM Wolfgang Jeltsch <<a href="mailto:g9ks157k@acme.softbase.org">g9ks157k@acme.softbase.org</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
my STRefs have the RealWorld parameter. For now, I do not unpack the<br>
STRefs, but wrap them with the IORef constructor and use mkWeakIORef on<br>
the resulting IORef. I guess this should be sane. Is there any reason<br>
why this should not work?<br>
<br>
All the best,<br>
Wolfgang<br>
<br>
Am Montag, den 01.12.2014, 21:21 +0000 schrieb John Lato:<br>
> Really a function like mkWeakIORef should be exposed for STRef's. I<br>
> know there's supposed to be a patch to normalize various weak'ish<br>
> things (ekmett?), maybe that function could be added at the same<br>
> time.<br>
><br>
> Until then, I would suggesy unpacking the STRef to get at the<br>
> underlying MutVar#, and copy the IORef code (which IIRC also works on<br>
> MutVar#) to write the function yourself.<br>
><br>
> John L.<br>
><br>
> On 07:56, Mon, Dec 1, 2014 Wolfgang Jeltsch<br>
> <<a href="mailto:g9ks157k@acme.softbase.org" target="_blank">g9ks157k@acme.softbase.org</a>> wrote:<br>
>         Hi,<br>
><br>
>         I need to convert values of types STRef RealWorld a to IORef a<br>
>         in order<br>
>         to attach finalizers to them. For now, I am using GHC.IORef<br>
>         for this. Is<br>
>         there a better way to achieve what I want?<br>
><br>
>         All the best,<br>
>         Wolfgang<br>
><br>
>         ______________________________<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>
<br>
______________________________<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>