[Haskell-cafe] Re: ANN: System.FilePath 0.9
Robert Dockins
robdockins at fastmail.fm
Wed Jul 26 14:15:34 EDT 2006
On Jul 26, 2006, at 1:47 PM, Neil Mitchell wrote:
> Hi,
>
>> Perhaps instead:
>>
>> directoryOf :: FilePath -> String
>> filenameOf :: FilePath -> String
>> extensionOf :: FilePath -> String
>> basenaneOf :: FilePath -> String
>>
>> replaceFilename = joinFilePath . directoryOf
>> replaceDirectory = flip joinFilePath . filenameOf
>
> Trying to design a consistent naming system, it helps if we all agree
> on what the various parts of a filepath are called, this is my draft
> of that:
>
> http://www-users.cs.york.ac.uk/~ndm/temp/filepath.png
>
> With a better name for basename, if anyone can think of one.
"stem", perhaps? You could also, maybe, distinguish the "short
stem" (everything before the "extensions") from the "long stem"
everything before the "extension".
> Once we have that, how about
>
> takeElement :: FilePath -> String
> dropElement :: FilePath -> String
> replaceElement :: FilePath -> String -> FilePath
> addElement :: FilePath -> String -> FilePath
> splitElement :: FilePath -> (String, String)
> joinElement :: String -> String -> FilePath
>
> With the restriction that not all of these are provided. Some don't
> make sense (splitBaseName, dropBaseName), some are implemented via
> combine (addFileName, joinFileName), some are redundant (addExtensions
> == addExtension)
>
> I'm also debating whether split/join should be exported, since they
> are less likely to be used and can easily be written as a take/drop
> pair. And of course, a bigger interface is harder to understand.
>
> Opinions on this? It's easier to tweak a specification than the
> actual code :)
>
> Thanks
>
> Neil
Rob Dockins
Speak softly and drive a Sherman tank.
Laugh hard; it's a long way to the bank.
-- TMBG
More information about the Haskell-Cafe
mailing list