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
signature.asc
Description: Digital signature
_______________________________________________ darcs-devel mailing list darcs-devel@darcs.net http://lists.osuosl.org/mailman/listinfo/darcs-devel