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