We should replace direct use of the IO monad in Darcs with a customised
monad that abstracts away various things. This is important to make the
Darcs library properly usable.
- The use of global IORefs (use ReaderT instead? - still with IORefs,
but not ones defined using the global variables hack)
- The use of exit/exitWith and atexit handlers (replace with a custom
exception type and finally blocks?)
- (perhaps) things like progress reports
- The mechanism for working with directories (see issue1774 and related
discussion)
- output to stdout/stderr
- (perhaps) all the other IO Darcs does
A good starting point would be to newtype wrap the IO monad, and
implement MonadIO. The downside is that this would involve putting
liftIO in all over the place, which would be quite ugly, but the
advantage is that it would be essentially mechanical.
Once that's in place we could gradually move things into the monad.
One thing to keep a close eye at each step on would be performance.
|