[reactive] Bug fixes in progress

Svein Ove Aas svein.ove at aas.no
Sun May 31 17:04:24 EDT 2009


On Sat, May 30, 2009 at 5:48 PM, Bertram Felgenhauer
<bertram.felgenhauer at googlemail.com> wrote:
> Sterling Clover wrote:
>> 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.
>
Let's call it restartingUnsafePerformIO, though. It's not in any way
"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


More information about the Reactive mailing list