[Haskell-cafe] RE: ANN: System.FilePath 0.9

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Wed Jul 26 15:44:52 EDT 2006

On Wed, 2006-07-26 at 11:32 -0700, Andrew Pimlott wrote:
> On Wed, Jul 26, 2006 at 03:36:13AM +0100, Neil Mitchell wrote:
> > >> Its a rats nest to do it properly, but some very basic idea of "does
> > >> this path have things which there is no way could possibly be in a
> > >> file" - for example c:\|file is a useful thing to have.
> > >
> > >This seems to encourage the classic mistake of checking "not known bad"
> > >rather than "known good".  "known bad" is rarely useful in my
> > >experience.  What use case do you have in mind?
> > 
> > wget on windows saves web pages such as
> > "http://www.google.com/index.html?q=haskell" to the file
> > "index.html?q=haskell". This just doesn't work, and is the main reason
> > I added this in. I don't think it will be a commonly used operation.
> Ok, this is a good use case.  What should wget do if "isValid" fails?
> Certainly not abort the download.  So isValid alone is no help.  Well,
> you have makeValid as well, but this is even more of a rats' nest.
> There are a zillion different ways you might want this function to work,
> depending on your purposes.  Should makeValid be system-dependent?
> Should it be reversible?  How hard should it try to preserve the name
> verbatim?  Should it "prettify" legal but unprintable characters?  The
> answers are application-dependent.  Also, wget has to worry about not
> just whether the filename is valid, but whether it currently exists, and
> in that case modify it.  So attempting to provide a generic makeValid is
> quixotic and will only lead to misuse.

Perhaps we should be more specific and make it talk about illegal file
name characters if that is indeed the use case. Perhaps we should
provide a system-dependent list of characters that are not allowed in
file names. For example, on windows that would include '?'.

Then an application can decide for itself what to do about that
depending on the context. It might be able to tell the user to pick a
different name, or in the wget case replace it with a different
character or remove it or something.

So maybe we should keep isValid but specify exactly what it checks. Then
if it fails it's up to the application to decide how to fix it, possibly
making use of the list of illegal characters.


More information about the Haskell-Cafe mailing list