I&#39;ve pushed Svein&#39;s patch, plus some small tweaks of my own, to the darcs repo at <a href="http://code.haskell.org/unamb">http://code.haskell.org/unamb</a> .  Comments, please.  I have a pretty tenuous grip on this block/unblock/retry stuff.<br>

<br>  - Conal<br><br><div class="gmail_quote">On Sun, May 31, 2009 at 2:04 PM, Svein Ove Aas <span dir="ltr">&lt;<a href="mailto:svein.ove@aas.no">svein.ove@aas.no</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

On Sat, May 30, 2009 at 5:48 PM, Bertram Felgenhauer<br>
<div class="im">&lt;<a href="mailto:bertram.felgenhauer@googlemail.com">bertram.felgenhauer@googlemail.com</a>&gt; wrote:<br>
</div><div class="im">&gt; Sterling Clover wrote:<br>
&gt;&gt; This is perhaps a silly idea, but perhaps useful -- there should be a<br>
&gt;&gt; version of unsafePerformIO that always does the &quot;right&quot; thing with regards<br>
&gt;&gt; to exceptions. From that, the other unamb primitives can perhaps be built<br>
&gt;&gt; more obviously? Additionally, this implementation would be potentially<br>
&gt;&gt; useful to libraries beyond unamb.<br>
&gt;<br>
&gt; You mean something like this?<br>
&gt;<br>
&gt; -- | A version of &#39;unsafePerformIO&#39; that assures that the resulting<br>
&gt; --   (pure) computation can be restarted if it is killed by an<br>
&gt; --   asynchronous exception. Note that as a result, the IO action<br>
&gt; --   may be performed more than once.<br>
&gt; exceptionSafeUnsafePerformIO act = unsafePerformIO $ retry act<br>
&gt;    where<br>
&gt;        retry act = unblock act `catch` \SomeException e -&gt; do<br>
&gt;             myid &lt;- myThreadId<br>
&gt;             throwTo myid e<br>
&gt;             retry act<br>
&gt;<br>
&gt; That could be useful indeed.<br>
&gt;<br>
</div>Let&#39;s call it restartingUnsafePerformIO, though. It&#39;s not in any way<br>
&quot;safer&quot; than the normal one - in a number of circumstances it&#39;s less<br>
safe.<br>
<br>
<br>
Besides that, I&#39;ve turned in a patch documenting this discussion in<br>
Unamb.hs. You can see the resulting commentary in<br>
<a href="http://brage.info/%7Esvein/unamb.patch" target="_blank">http://brage.info/~svein/unamb.patch</a> for the time being; feel free to<br>
tell me it&#39;s mistaken in some respect.<br>
<br>
--<br>
<font color="#888888">Svein Ove Aas<br>
</font><div><div></div><div class="h5">_______________________________________________<br>
Reactive mailing list<br>
<a href="mailto:Reactive@haskell.org">Reactive@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/reactive" target="_blank">http://www.haskell.org/mailman/listinfo/reactive</a><br>
</div></div></blockquote></div><br>