I've pushed Svein'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"><<a href="mailto:svein.ove@aas.no">svein.ove@aas.no</a>></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"><<a href="mailto:bertram.felgenhauer@googlemail.com">bertram.felgenhauer@googlemail.com</a>> wrote:<br>
</div><div class="im">> Sterling Clover wrote:<br>
>> This is perhaps a silly idea, but perhaps useful -- there should be a<br>
>> version of unsafePerformIO that always does the "right" thing with regards<br>
>> to exceptions. From that, the other unamb primitives can perhaps be built<br>
>> more obviously? Additionally, this implementation would be potentially<br>
>> useful to libraries beyond unamb.<br>
><br>
> You mean something like this?<br>
><br>
> -- | A version of 'unsafePerformIO' that assures that the resulting<br>
> -- (pure) computation can be restarted if it is killed by an<br>
> -- asynchronous exception. Note that as a result, the IO action<br>
> -- may be performed more than once.<br>
> exceptionSafeUnsafePerformIO act = unsafePerformIO $ retry act<br>
> where<br>
> retry act = unblock act `catch` \SomeException e -> do<br>
> myid <- myThreadId<br>
> throwTo myid e<br>
> retry act<br>
><br>
> That could be useful indeed.<br>
><br>
</div>Let's call it restartingUnsafePerformIO, though. It's not in any way<br>
"safer" than the normal one - in a number of circumstances it's less<br>
safe.<br>
<br>
<br>
Besides that, I'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'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>