Proposal: Add System.FilePath to base

Neil Mitchell ndmitchell at
Thu Nov 23 05:55:12 EST 2006


> isDirectory :: FilePath -> Bool
> isFile :: FilePath -> Bool
> asDirectory :: FilePath -> FilePath
> asFile :: FilePath -> FilePath
> At the least, they are confusingly named, because
>    forall x. isDirectory (takeDirectory x) == False
> (and I definitely don't suggest fixing this by making takeDirectory append a
> path separator).
> The point is, the absence of a path separator at the end of a FilePath does not
> imply that the FilePath refers to a file rather than a directory.
> If we must have these, then I suggest renaming them:
>    hasTrailingPathSeparator :: FilePath -> Bool
>    addTrailingPathSeparator :: FilePath -> FilePath
>    dropTrailingPathSeparator :: FilePath -> FilePath

Ok, that sounds entirely reasonable. I actually prefer the long names
- it encourages people not to use them! I don't suspect these will be
widely used, however some people found these were the single place
where they needed to get into a FilePath and do string manipulation -
something I'd really like to discourage.

> Also, what's going on with System.FilePath.Windows and System.FilePath.Posix?
> Their documentation is empty.  CPP shenanigans?

The documentation for System.FilePath.Windows and Posix are both
identical to System.FilePath - they export exactly the same API and
have exactly the same semantics, just tied to either Windows: or
Posix: properties given in the main one. I'll update the text in these
to modules
to make this more clear.



More information about the Libraries mailing list