[darcs-devel] RT #303

Aaron Denney wnoise at ofb.net
Sat Apr 2 19:38:37 PST 2005


So, I've been taking a look at #303, which looked fairly easy.
http://bugs.darcs.net//Ticket/Display.html?id=303

Then I realized that the commands themselves don't check for whether
they can run, but that this is encapsulated in a 'command_prereq' field
of a record.  This does more than check whether the command
can run -- it also returns a FilePath saying how to locate the root of
the repository, and a (possibly empty) string describing an error.

I think the name command_prereq is rather misleading, as the only
thing it currently is used for is to verify that we're in a repo (or
the opposite for init, and get doesn't care).  How about
"command_locate_repo_root", with "am_in_repo" renamed to
"locate_root_in_repo", and "am_not_in_repo" renamed to
"root_of_new_repo"?

Further, I think that rather than returning "IO (Maybe FilePath, String)",
that returning Either FilePath String would be appropriate, making it
clear that the message really isn't used when the FilePath is there.
As a bonus, it'd now be usable as an error monad.

Fixing #303 should just requires amending the last line of "am_not_in_repo"
to 
else return $ (Just "", "You may not run that command in a repository.")

David, let me know if you'll take patches for
(a) renaming
(b) changing the type
(c) the error message.

-- 
Aaron Denney
-><-





More information about the darcs-devel mailing list