[darcs-devel] Re: [issue405] darcs send -o test.dpatch --repodir=somerepo leaves output file in repository directory

David Roundy droundy at darcs.net
Wed Jul 25 12:18:01 PDT 2007


On Tue, Jul 24, 2007 at 09:12:55PM +0200, Eric Y. Kow wrote:
> And since we're on the subject of random FilePath thoughts.  Would it be
> useful to distinguish between such paths in our types?  Are there errors
> we could avoid with this?
> 
> data DarcsPath = RepoPath FilePath
>                | AbsPath  FilePath
>                | UserPath FilePath
> 
> Or would that just make things clunky?

I think that's worth considering.  Possibly we could even specify different
types:

newtype RepoPath = RepoPath FilePath
newtype AbsolutePath = AbsolutePath FilePath
newtype RelativePath = RelativePath FilePath

data DarcsPath = RepoDP RepoPath
               | AbsoluteDP AbsolutePath
               | RelativeDP RelativePath

Then we could make the typesystem ensure that certain paths are always
absolute (for instance, any path that is passed to a lazy IO function, so
that it won't get messed up if the current directory changes).

I'd certainly appreciate having this sort of documentation of which sort of
path is expected in certain functions.  It'd also mean that we could avoid
redundant calls converting paths to absolute by putting the requirement
into the type.

class FilePath p where
  toFilePath :: p -> FilePath
instance FilePath RepoPath
instance FilePath AbsolutePath
instance FilePath RelativePath
instance FilePath DarcsPath
instance FilePath FilePath

Then code that doesn't care what sort of FilePath is given could just be
polymorphic, which sounds like a good plan.

We also might want to distinguish possibly-remote filepaths.
-- 
David Roundy
Department of Physics
Oregon State University
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.osuosl.org/pipermail/darcs-devel/attachments/20070725/10cf8ca6/attachment.pgp


More information about the darcs-devel mailing list