[darcs-devel] [darcs #183] Implement withDelayedTempDir

David Roundy droundy at abridgegame.org
Mon Jan 24 04:22:41 PST 2005


On Mon, Jan 24, 2005 at 12:04:11PM +0100, Tomasz Zielonka wrote:
> On Mon, Jan 24, 2005 at 02:24:12AM +0100, Juliusz Chroboczek wrote:
> > > You can use unsafePerformIO to bind the result of an IO computation as a
> > > top-level value.
> > 
> > Any chance you could implement this?  It looks like that requires
> > understanding mvars, the GHC inliner, and Haskell exceptions (of which
> > I understand there are various kinds), so it's a little beyond me.
> > 
> > Say something like
> > 
> >   atexit :: IO () -> IO ()
> > 
> > which registers an action to be executed at program exit.  (It needs
> > to be safe against exceptions, of course.)
> 
> OK, I'll do it. I am not a GHC's exceptions guru yet, but I'm trying to
> understand the issues for another development effort.
> 
> In case of atexit we'll have to deal with two sources of exceptions:
>  - asynchronous exceptions raised when registering an action
>      (these can be dealt with by using a safe MVar operations
>      like modifyMVar_)
>  - exceptions raised by one or more registered action at program exit
>     (what to do with them - report and ignore?)

I think we can get by without the atexit--instead use bracket in some early
darcs code, as we already do by calling withSignalsHandled as a wrapper in
main (in darcs.lhs).  I believe this should catch everything, although
there are certain situations when stderr gets closed and is unwriteable
which cause the exception handlers to throw exceptions, which seem to cause
some handlers to not get run.

Of course, one must be sure to use Control.Exception.bracket, since the
bracket in the prelude is pretty close to worthless...
-- 
David Roundy
http://www.darcs.net




More information about the darcs-devel mailing list