[darcs-devel] Re: darcs patch: Make annotate work on files with spaces in the name

David Roundy droundy at darcs.net
Wed Dec 27 05:33:15 PST 2006


On Tue, Dec 26, 2006 at 04:50:17PM +0100, Benedikt Schmidt wrote:
> David Roundy <droundy at darcs.net> writes:
> > Hmmm.  It seems to me like it could be done more cleanely with a
> > modification to apply and WritableDirectory.  But I suspect that your code
> > could relatively easily be refactored in that direction if we thought it
> > advisable, wouldn't you think?
> 
> Yes, that would be nicer. I'll take another look to see if i can use this
> approach with monad transformers. I had some problems with creating
> withFoo :: String -> m a -> m a
> methods when using monad transformers, since I didn't find a way
> to reuse the method from the inner monad.
> 
> A simple lift doesn't work here since you need
> withFoo :: String -> StateT s m a -> StateT s m a
> and only have withFoo :: String -> m a -> m a .

Hmmm.  I must admit that I'm pretty ignorant regarding monad
transformers...

> > Just out of curiosity, what is the slurpy needed for? Is it just to do
> > the two things at once, or do you actually need it for updating the
> > cache?
> 
> The base State layer is just responsible for keeping track of which
> files are modified, e.g.
> 
> instance WriteableDirectory m => WriteableDirectory (CacheMonad m) where
>     mRemoveFile fn =  do appendFn (RemoveFile fn)
>                          lift $ mRemoveFile fn
> 
> the ReadableDirectory instance uses the inner monad (slurpy in this case)
> to keep track of renames, file contents, etc which are used by apply.
> 
> instance ReadableDirectory m => ReadableDirectory (CacheMonad m) where
>     mDoesDirectoryExist = lift . mDoesDirectoryExist

I suspect that you can do without the inner monad.  You might take a look
at the FilePathMonad.  This involves a Readable/WriteableDirectory monad
that doesn't store most of the information, and works fine.

Actually, apply pretty exclusively uses the WriteableDirectory functions,
so stubs for the ReadableDirectory routines are pretty harmless (there is
one mDoesDirectoryExist, used for setpref... but if you always return
false, you're safe).  It may be that we should modify the interface to
remove some of these unused functions, although I'd hate to do that, as
it'd make the interface less generally useful.  Still, if the policy is
that some functions don't need to be properly implemented, then it would
probably be a good idea simply to remove those functions...

And incidentally, I am now engaged to my girlfriend, Monica! :) :) :)
-- 
David Roundy
http://www.darcs.net


More information about the darcs-devel mailing list